Skip to content
This repository
Browse code

Merge pull request #1506 from Montellese/jsonrpc_http_get

webserver: add support for passing JSON-RPC requests through HTTP GET arguments
  • Loading branch information...
commit f6744049923e782ff4c37250de8ae7f6f1f849ff 2 parents c5848e9 + 331afa3
Sascha Montellese authored October 05, 2012
19  xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp
@@ -39,6 +39,7 @@ bool CHTTPJsonRpcHandler::CheckHTTPRequest(const HTTPRequest &request)
39 39
 int CHTTPJsonRpcHandler::HandleHTTPRequest(const HTTPRequest &request)
40 40
 {
41 41
   CHTTPClient client;
  42
+  bool isRequest = false;
42 43
   if (request.method == POST)
43 44
   {
44 45
     string contentType = CWebServer::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE);
@@ -50,8 +51,24 @@ int CHTTPJsonRpcHandler::HandleHTTPRequest(const HTTPRequest &request)
50 51
       return MHD_YES;
51 52
     }
52 53
 
53  
-    m_response = CJSONRPC::MethodCall(m_request, request.webserver, &client);
  54
+    isRequest = true;
54 55
   }
  56
+  else if (request.method == GET)
  57
+  {
  58
+    map<string, string> arguments;
  59
+    if (CWebServer::GetRequestHeaderValues(request.connection, MHD_GET_ARGUMENT_KIND, arguments) > 0)
  60
+    {
  61
+      map<string, string>::const_iterator argument = arguments.find("request");
  62
+      if (argument != arguments.end() && !argument->second.empty())
  63
+      {
  64
+        m_request = argument->second;
  65
+        isRequest = true;
  66
+      }
  67
+    }
  68
+  }
  69
+
  70
+  if (isRequest)
  71
+    m_response = CJSONRPC::MethodCall(m_request, request.webserver, &client);
55 72
   else
56 73
   {
57 74
     // get the whole output of JSONRPC.Introspect

0 notes on commit f674404

Please sign in to comment.
Something went wrong with that request. Please try again.