From ac31e5e8847087cc7bd672a8afb755086faa6461 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 23 Nov 2024 21:44:03 +0900 Subject: [PATCH] Ready use the JSON-RPC 2.0 based stateless proxy --- lib/http.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/http.js b/lib/http.js index fb0b19a..5f7113d 100644 --- a/lib/http.js +++ b/lib/http.js @@ -490,9 +490,21 @@ var HTTPObject = function(engine) { } if (this.proxy.type == "stateless-jsonrpc2") { - // todo + data = JSON.stringify( + JsonRpc2.wrap(this.proxy.rpcMethod, { + "method": this.proxy.method, + "url": url, + "headers": this.getRequestHeaders(function(x) { + return Object.keys(x).reduce(function(a, k) { + a.push(x[k]); + return a; + }, []); + }), + "data": data + }, "") + ); } - + return data; }; @@ -618,7 +630,7 @@ var HTTPObject = function(engine) { console.log("Use the engine:", this.engine); } } catch (e) { - console.error("HTTPObject.open() ->", e.message); + console.error("Exception on HTTPObject.open():", e.message); } return this; @@ -1283,7 +1295,7 @@ exports.parseURL = parseURL; exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT; exports.defaultUserAgent = DEFAULT_USER_AGENT; // compatible -exports.VERSIONINFO = "HTTP Client for WelsonJS framework (http.js) version 0.7.41"; +exports.VERSIONINFO = "HTTP Client for WelsonJS framework (http.js) version 0.7.42"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;