mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
[lib/http] cURL error with non-escaped ampersand on Command Prompt #103
This commit is contained in:
parent
541078bda8
commit
166dd70ef9
34
lib/http.js
34
lib/http.js
|
@ -372,9 +372,9 @@ var HTTPObject = function(engine) {
|
|||
break;
|
||||
|
||||
default:
|
||||
console.warn("Switching the engine to cURL. Not supported method in MSXML: " + method);
|
||||
this.setEngine("CURL");
|
||||
console.log("Opened engine:", this.engine);
|
||||
console.warn("Switching the engine to cURL. Not supported method in MSXML: " + method);
|
||||
this.setEngine("CURL");
|
||||
console.log("Opened engine:", this.engine);
|
||||
}
|
||||
} else {
|
||||
console.log("Opened engine:", this.engine);
|
||||
|
@ -390,6 +390,30 @@ var HTTPObject = function(engine) {
|
|||
var responseText = null;
|
||||
var debuggingText = null;
|
||||
|
||||
// [lib/http] cURL error with non-escaped ampersand on Command Prompt #103
|
||||
var replaceAndExcludeCaretAnd = function(inputString) {
|
||||
var result = "";
|
||||
var i = 0;
|
||||
|
||||
while (i < inputString.length) {
|
||||
// If the found position is ^&, do not modify and add it as is to the result
|
||||
if (i < inputString.length - 1 && inputString.slice(i, i + 2) === "^&") {
|
||||
result += inputString.slice(i, i + 2);
|
||||
i += 2;
|
||||
} else {
|
||||
// Replace & with ^&
|
||||
if (inputString.charAt(i) === "&") {
|
||||
result += "^&";
|
||||
} else {
|
||||
result += inputString.charAt(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
if (this.contentType != null) {
|
||||
this.setHeader("Content-Type", this.contentType);
|
||||
}
|
||||
|
@ -478,7 +502,7 @@ var HTTPObject = function(engine) {
|
|||
// Add the request body if this is not GET method
|
||||
if (this.method !== "GET") {
|
||||
cmd.push("-d");
|
||||
cmd.push(this.serialize());
|
||||
cmd.push(replaceAndExcludeCaretAnd(this.serialize()));
|
||||
}
|
||||
|
||||
// Add proxy: <[protocol://][user:password@]proxyhost[:port]>
|
||||
|
@ -968,7 +992,7 @@ exports.patch = patch;
|
|||
exports.put = put;
|
||||
exports._delete = _delete;
|
||||
|
||||
exports.VERSIONINFO = "HTTP Library (http.js) version 0.7.11";
|
||||
exports.VERSIONINFO = "HTTP request module (http.js) version 0.7.12";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user