mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-12 00:45:14 +00:00
Update http.js
This commit is contained in:
parent
98b49b80a1
commit
92fdc2ff57
31
lib/http.js
31
lib/http.js
|
@ -37,7 +37,7 @@ var HTTPObject = function(engine) {
|
|||
this.engine = (typeof(engine) !== "undefined" ? engine : "MSXML");
|
||||
|
||||
this.cookie = null;
|
||||
this.storedCookie = PipeIPC.create("volatile");
|
||||
this.storedCookie = PipeIPC.connect("volatile");
|
||||
this.states = [];
|
||||
this.variables = {
|
||||
"uuidv4": RAND.uuidv4,
|
||||
|
@ -117,7 +117,6 @@ var HTTPObject = function(engine) {
|
|||
return this;
|
||||
};
|
||||
|
||||
|
||||
this.jqEnabled = function() {
|
||||
return (typeof(window) !== "undefined" && typeof(window.jQuery) !== "undefined");
|
||||
};
|
||||
|
@ -440,6 +439,7 @@ var HTTPObject = function(engine) {
|
|||
}
|
||||
|
||||
try {
|
||||
// MSXML (XHR)
|
||||
if (this.engine == "MSXML") {
|
||||
for (var key in this.headers) {
|
||||
_interface.setRequestHeader(key, this.evaluate(this.headers[key]));
|
||||
|
@ -459,7 +459,10 @@ var HTTPObject = function(engine) {
|
|||
|
||||
// Get response text
|
||||
responseText = _interface.responseText;
|
||||
} else if (this.engine == "CURL") {
|
||||
}
|
||||
|
||||
// cURL
|
||||
else if (this.engine == "CURL") {
|
||||
if (this.states.length > 0) {
|
||||
// Make CURL context
|
||||
var state = this.states[this.states.length - 1];
|
||||
|
@ -604,6 +607,26 @@ var HTTPObject = function(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];
|
||||
var cmd = ["/transfer", job_name];
|
||||
var url = state.url;
|
||||
var out = PipeIPC.connect("volatile");
|
||||
|
||||
if (this.method !== "GET") {
|
||||
cmd = cmd.concat(["/download", "/priority", job_priority, url, out.path]);
|
||||
_interface.exec(cmd);
|
||||
out.reload();
|
||||
responseText = out.read()
|
||||
|
||||
var err = _interface.exec(["/geterror", job_name]);
|
||||
debuggingText = err.stdout.read();
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof responseText === "string") {
|
||||
console.log("Received", responseText.length, "bytes");
|
||||
} else {
|
||||
|
@ -1062,7 +1085,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.20";
|
||||
exports.VERSIONINFO = "HTTP client module (http.js) version 0.7.21";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user