From 4a24bca069edc2830fc17ab27ba54560435b778b Mon Sep 17 00:00:00 2001 From: elij Date: Sat, 28 May 2011 14:14:34 -0700 Subject: restructure the html/rpc.php endpoint - move request_method test to the top, and catch other request types (HEAD, PUT, etc) - change how html output is handled. instead of building a string, just output the html - set appropriate response header for incorrect request_method. Signed-off-by: Lukas Fleischer --- web/html/rpc.php | 61 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'web') diff --git a/web/html/rpc.php b/web/html/rpc.php index 1a9ca34..b2c244b 100644 --- a/web/html/rpc.php +++ b/web/html/rpc.php @@ -1,36 +1,41 @@ handle($_GET); - } - else { - // dump a simple usage output for people to use. - // this could be moved to an api doc in the future, or generated from - // the AurJSON class directly with phpdoc. For now though, just putting it here. - echo ''; - echo 'The methods currently allowed are:
'; - echo '
'; - echo 'Each method requires the following HTTP GET syntax:
'; - echo '   type=methodname&arg=data

'; - echo 'Where methodname is the name of an allowed method, and data is the argument to the call.
'; - echo '
'; - echo 'If you need jsonp type callback specification, you can provide an additional variable callback.
'; - echo 'Example URL:
   http://aur-url/rpc.php?type=search&arg=foobar&callback=jsonp1192244621103'; - echo ''; - } +if ( $_SERVER['REQUEST_METHOD'] != 'GET' ) { + header('HTTP/1.1 405 Method Not Allowed'); + exit(); +} + +if ( isset($_GET['type']) ) { + $rpc_o = new AurJSON(); + echo $rpc_o->handle($_GET); } else { - echo 'POST NOT SUPPORTED'; + // dump a simple usage output for people to use. + // this could be moved to an api doc in the future, or generated from + // the AurJSON class directly with phpdoc. For now though, just putting it + // here. +?> + +The methods currently allowed are:
+
+Each method requires the following HTTP GET syntax:
+   type=methodname&arg=data +

+Where methodname is the name of an allowed method, and data is the argument to the call. +

+If you need jsonp type callback specification, you can provide an additional variable callback. +
+Example URL:
+    http://aur-url/rpc.php?type=search&arg=foobar&callback=jsonp1192244621103 + + -- cgit v1.2.3-70-g09d2