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