mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 04:31:04 +00:00
Update http.js
This commit is contained in:
parent
1309e2ab8f
commit
b3a4125253
86
lib/http.js
86
lib/http.js
|
@ -79,44 +79,30 @@ var HTTPObject = function(engine) {
|
|||
this.isCompressedResponse = false;
|
||||
|
||||
this.create = function() {
|
||||
switch (this.engine) {
|
||||
case "MSXML":
|
||||
if (typeof XMLHttpRequest !== "undefined") {
|
||||
console.log("A");
|
||||
this._interface = new XMLHttpRequest();
|
||||
} else {
|
||||
console.log("B");
|
||||
this._interface = CreateObject([
|
||||
"Microsoft.XMLHTTP",
|
||||
"WinHttp.WinHttpRequest.5.1",
|
||||
"Msxml3.XMLHTTP",
|
||||
"Msxml2.XMLHTTP",
|
||||
"Msxml2.XMLHTTP.7.0",
|
||||
"Msxml2.XMLHTTP.6.0",
|
||||
"Msxml2.XMLHTTP.5.O",
|
||||
"Msxml2.XMLHTTP.4.O",
|
||||
"Msxml2.XMLHTTP.3.O",
|
||||
"Msxml2.XMLHTTP.2.6",
|
||||
"Msxml2.ServerXMLHTTP",
|
||||
"Msxml2.ServerXMLHTTP.6.0",
|
||||
"Msxml2.ServerXMLHTTP.5.0",
|
||||
"Msxml2.ServerXMLHTTP.4.0",
|
||||
"Msxml2.ServerXMLHTTP.3.0"
|
||||
]);
|
||||
}
|
||||
break;
|
||||
|
||||
case "CURL":
|
||||
console.log("C");
|
||||
this._interface = SHELL.create();
|
||||
this._interface.setPrefix("bin\\curl.exe"); // the location of cURL binary
|
||||
break;
|
||||
|
||||
case "BITS":
|
||||
console.log("D");
|
||||
this._interface = SHELL.create();
|
||||
this._interface.setPrefix("bitsadmin.exe"); // the location of BITS binary
|
||||
break;
|
||||
if (this.engine == "MSXML") {
|
||||
this._interface = typeof XMLHttpRequest !== "undefined" ? new XMLHttpRequest() : CreateObject([
|
||||
"Microsoft.XMLHTTP",
|
||||
"WinHttp.WinHttpRequest.5.1",
|
||||
"Msxml3.XMLHTTP",
|
||||
"Msxml2.XMLHTTP",
|
||||
"Msxml2.XMLHTTP.7.0",
|
||||
"Msxml2.XMLHTTP.6.0",
|
||||
"Msxml2.XMLHTTP.5.O",
|
||||
"Msxml2.XMLHTTP.4.O",
|
||||
"Msxml2.XMLHTTP.3.O",
|
||||
"Msxml2.XMLHTTP.2.6",
|
||||
"Msxml2.ServerXMLHTTP",
|
||||
"Msxml2.ServerXMLHTTP.6.0",
|
||||
"Msxml2.ServerXMLHTTP.5.0",
|
||||
"Msxml2.ServerXMLHTTP.4.0",
|
||||
"Msxml2.ServerXMLHTTP.3.0"
|
||||
]);
|
||||
} else if (this.engine == "CURL") {
|
||||
this._interface = SHELL.create();
|
||||
this._interface.setPrefix("bin\\curl.exe"); // the location of cURL binary
|
||||
} else if (this.engine == "BITS") {
|
||||
this._interface = SHELL.create();
|
||||
this._interface.setPrefix("bitsadmin.exe"); // the location of BITS binary
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -443,11 +429,7 @@ var HTTPObject = function(engine) {
|
|||
this.setHeader("Content-Type", this.contentType);
|
||||
}
|
||||
|
||||
console.log("engine: ", this.engine);
|
||||
console.log("interface: ", typeof this._interface);
|
||||
|
||||
try {
|
||||
// MSXML (XHR)
|
||||
if (this.engine == "MSXML") {
|
||||
for (var key in this.headers) {
|
||||
this._interface.setRequestHeader(key, this.evaluate(this.headers[key]));
|
||||
|
@ -467,14 +449,11 @@ var HTTPObject = function(engine) {
|
|||
|
||||
// Get response text
|
||||
responseText = this._interface.responseText;
|
||||
}
|
||||
|
||||
// cURL
|
||||
else if (this.engine == "CURL") {
|
||||
} else if (this.engine == "CURL") {
|
||||
if (this.states.length > 0) {
|
||||
// Make CURL context
|
||||
var state = this.states[this.states.length - 1];
|
||||
var cmd = [];
|
||||
var cmd = ["bin\\curl"];
|
||||
var url = state.url;
|
||||
|
||||
if (this.isDebugging) {
|
||||
|
@ -604,19 +583,16 @@ var HTTPObject = function(engine) {
|
|||
console.log("Detected charset:", detectedCharset);
|
||||
|
||||
if (detectedCharset != null && this.charset != detectedCharset) {
|
||||
var this._interface = SHELL.create();
|
||||
responseText = this._interface.setCharset(detectedCharset).exec(cmd);
|
||||
debuggingText = this._interface.stderr.read();
|
||||
var _interface = SHELL.create();
|
||||
responseText = _interface.setCharset(detectedCharset).exec(cmd);
|
||||
debuggingText = _interface.stderr.read();
|
||||
}
|
||||
}
|
||||
|
||||
// Get debuging text
|
||||
debuggingText = this._interface.stderr.read();
|
||||
}
|
||||
}
|
||||
|
||||
// BITS
|
||||
else if (this.engine == "BITS") {
|
||||
} else if (this.engine == "BITS") {
|
||||
var job_name = "welsonjs_" + PipeIPC.UUIDv4.create().substring(0, 8);
|
||||
var job_priority = "normal";
|
||||
var state = this.states[this.states.length - 1];
|
||||
|
@ -1095,7 +1071,7 @@ exports.parseURL = parseURL;
|
|||
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
|
||||
exports.defaultUserAgent = DEFAULT_USER_AGENT; // compatible with the specific case
|
||||
|
||||
exports.VERSIONINFO = "HTTP client module (http.js) version 0.7.21";
|
||||
exports.VERSIONINFO = "HTTP client module (http.js) version 0.7.22";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user