From 1ae2c7a814c90a1ee45c6d7d526b55b1fed81481 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 17 Jan 2022 18:44:31 +0900 Subject: [PATCH] Update http.js --- lib/http.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/http.js b/lib/http.js index 7dc9804..0ce9dc2 100644 --- a/lib/http.js +++ b/lib/http.js @@ -234,14 +234,14 @@ var HTTPObject = function(engine) { } }; - this.serializeURL = function(parametersObject) { - var str = []; - for (var k in parametersObject) { - if (parametersObject.hasOwnProperty(k)) { - str.push(encodeURIComponent(k) + "=" + encodeURIComponent(parametersObject[k])); + this.serializeURL = function(parameters) { + var s = []; + for (var k in parameters) { + if (parameters.hasOwnProperty(k)) { + s.push(encodeURIComponent(k) + "=" + encodeURIComponent(parameters[k])); } } - return str.join("&"); + return s.join("&"); }; // Type 1: http://domain?a=1&b=2&c=3 @@ -279,11 +279,9 @@ var HTTPObject = function(engine) { }; this.open = function(method, url) { - var url = this.serializeParameters(url); - this.setMethod(method.toUpperCase()); // set method - this.pushState(null, null, url); // push stat this.setHeader("User-Agent", (this.userAgent != null ? this.userAgent : '')); // set user agent + this.pushState(null, null, this.serializeParameters(url)); // push state try { if (this.engine == "MSXML") { @@ -361,14 +359,12 @@ var HTTPObject = function(engine) { cmd.push("-A"); cmd.push((this.userAgent != null ? this.userAgent : '')); - /* - var pos = url.indexOf('?'); - if (pos > -1) { + // Add the request body if this is not GET method + if (this.method !== "GET") { cmd.push("-d"); - cmd.push(state.url.substring(pos + 1)); + cmd.push(this.requestBody); } - */ - + cmd.push(state.url); // Get response text