diff options
author | Derrell Lipman <derrell@samba.org> | 2006-10-02 20:39:31 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:20:31 -0500 |
commit | 882d352151bd05c37e18de8f8f619787f831a311 (patch) | |
tree | 84e7be0d80a80bdc4b54b71bd25ec51f2b806daf /jsonrpc/request.esp | |
parent | a22d785d7cdfbb662a0755552acfbf995d865d0c (diff) | |
download | samba-882d352151bd05c37e18de8f8f619787f831a311.tar.gz samba-882d352151bd05c37e18de8f8f619787f831a311.tar.bz2 samba-882d352151bd05c37e18de8f8f619787f831a311.zip |
r19051: JSON-RPC server work-in-progress. It's almost working.
(This used to be commit 6e9cb2ed1cf87aed322fd7821237d088c2fef340)
Diffstat (limited to 'jsonrpc/request.esp')
-rw-r--r-- | jsonrpc/request.esp | 55 |
1 files changed, 7 insertions, 48 deletions
diff --git a/jsonrpc/request.esp b/jsonrpc/request.esp index a8080d9dc7..d58a00069c 100644 --- a/jsonrpc/request.esp +++ b/jsonrpc/request.esp @@ -14,6 +14,7 @@ */ /* Bring in the date class */ +jsonrpc_include("json.esp"); jsonrpc_include("jsondate.esp"); /* bring the string functions into the global frame */ @@ -28,12 +29,6 @@ function printf() } -/* KLUDGE... */ -form = new Array(); -server = new Array(); -request = new Array(); -/* ...KLUDGE */ - /* * All of our manipulation of JSON RPC methods will be through this object. * Each class of methods will assign to here, and all of the constants will @@ -147,7 +142,7 @@ function sendReply(reply, scriptTransportId) if (scriptTransportId == jsonrpc.Constant.ScriptTransport.NotInUse) { /* ... then just output the reply. */ - printf(reply); + write(reply); } else { @@ -156,43 +151,11 @@ function sendReply(reply, scriptTransportId) "qx.io.remote.ScriptTransport._requestFinished(" + scriptTransportId + ", " + reply + ");"; - printf(reply); + write(reply); } } -/* - * class Json - * - * This class provides the JSON encoder and decoder, and some utility - * functions. - */ -Json = new Object(); - -/* KLUDGE... */ -function _jsonDecode(s) -{ - var o = new Object(); - o.id = 23; - o.service = "qooxdoo.test"; - o.method = "echo"; - o.params = new Array(1); - o.params[0] = "hello world"; - return o; -} -/* ...KLUDGE */ - -Json.decode = _jsonDecode; - -/* KLUDGE... */ -function _jsonEncode(o) -{ - return "{ result: \"hello world\" }" -} -/* ...KLUDGE */ - -Json.encode = _jsonEncode; - function _jsonValidRequest(req) { if (req == undefined) @@ -300,14 +263,14 @@ error = jsonrpc.createError(jsonrpc.Constant.ErrorOrigin.Server, scriptTransportId = jsonrpc.Constant.ScriptTransport.NotInUse; /* What type of request did we receive? */ -if (server["REQUEST_METHOD"] == "POST" && - server["CONENT_TYPE"] == "text/json") +if (request["REQUEST_METHOD"] == "POST" && + request["CONTENT_TYPE"] == "text/json") { /* We found literal POSTed json-rpc data (we hope) */ input = request["POST_DATA"]; jsonInput = Json.decode(input); } -else if (server["REQUEST_METHOD"] == "GET" && +else if (request["REQUEST_METHOD"] == "GET" && form["_ScriptTransport_id"] != undefined && form["_ScriptTransport_data"] != undefined) { @@ -318,10 +281,6 @@ else if (server["REQUEST_METHOD"] == "GET" && jsonInput = Json.decode(input); } -/* KLUDGE... */ -jsonInput = Json.decode(input); -/* ...KLUDGE */ - /* Ensure that this was a JSON-RPC service request */ if (! jsonrpc.validRequest(jsonInput)) { @@ -329,7 +288,7 @@ if (! jsonrpc.validRequest(jsonInput)) * This request was not issued with JSON-RPC so echo the error rather than * issuing a JsonRpcError response. */ - printf("JSON-RPC request expected; service, method or params missing<br>"); + write("JSON-RPC request expected; service, method or params missing<br>"); return; } |