mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Fix #111
This commit is contained in:
parent
14145d6f70
commit
b7ac95d8ea
52
lib/http.js
52
lib/http.js
|
@ -178,9 +178,15 @@ var HTTPObject = function(engine) {
|
|||
|
||||
this.setContentType = function(type) {
|
||||
this.contentType = type;
|
||||
this.setHeader("Content-Type", this.contentType);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.setCookie = function(cookie) {
|
||||
this.cookie = cookie;
|
||||
this.setHeader("Cookie", this.cookie);
|
||||
};
|
||||
|
||||
this.setRequestBody = function(data) {
|
||||
this.requestBody = data;
|
||||
return this;
|
||||
|
@ -196,10 +202,6 @@ var HTTPObject = function(engine) {
|
|||
return this;
|
||||
};
|
||||
|
||||
this.setCookie = function(cookie) {
|
||||
this.cookie = cookie;
|
||||
};
|
||||
|
||||
this.setHeaders = function(headers) {
|
||||
try {
|
||||
var headers = (typeof(headers) !== "undefined") ? headers : {};
|
||||
|
@ -360,7 +362,7 @@ var HTTPObject = function(engine) {
|
|||
|
||||
this.setMethod(method.toUpperCase()); // set method
|
||||
this.pushState(null, null, url); // push state
|
||||
this.setHeader("User-Agent", (this.userAgent != null ? this.evaluate(this.userAgent) : '')); // user agent
|
||||
this.setHeader("User-Agent", this.evaluate(this.userAgent)); // user agent
|
||||
|
||||
try {
|
||||
if (this.engine == "MSXML") {
|
||||
|
@ -395,27 +397,27 @@ var HTTPObject = function(engine) {
|
|||
|
||||
// [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 += "^&";
|
||||
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 {
|
||||
result += inputString.charAt(i);
|
||||
// Replace & with ^&
|
||||
if (inputString.charAt(i) === "&") {
|
||||
result += "^&";
|
||||
} else {
|
||||
result += inputString.charAt(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
if (this.contentType != null) {
|
||||
this.setHeader("Content-Type", this.contentType);
|
||||
|
@ -480,7 +482,7 @@ var HTTPObject = function(engine) {
|
|||
}
|
||||
|
||||
cmd.push("-A");
|
||||
cmd.push((this.userAgent != null ? this.evaluate(this.userAgent) : ''));
|
||||
cmd.push(this.evaluate(this.userAgent));
|
||||
|
||||
// --connect-timeout
|
||||
if (this.connectTimeout > 0) {
|
||||
|
@ -717,6 +719,8 @@ var HTTPObject = function(engine) {
|
|||
};
|
||||
|
||||
this.evaluate = function(str) {
|
||||
if (typeof str === "undefined" || str == null) return '';
|
||||
|
||||
var str = String(str);
|
||||
var Lpos = str.indexOf('{');
|
||||
var Rpos = str.indexOf('}', Lpos + 1);
|
||||
|
@ -1029,7 +1033,7 @@ exports.put = put;
|
|||
exports._delete = _delete;
|
||||
exports.parseURL = parseURL;
|
||||
|
||||
exports.VERSIONINFO = "HTTP request module (http.js) version 0.7.13";
|
||||
exports.VERSIONINFO = "HTTP request module (http.js) version 0.7.14";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user