mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-13 05:01:03 +00:00
Update http.js
This commit is contained in:
parent
512f0b4cb9
commit
6a13d9437b
32
lib/http.js
32
lib/http.js
|
@ -48,7 +48,9 @@ var HTTPObject = function(engine) {
|
||||||
password: ""
|
password: ""
|
||||||
};
|
};
|
||||||
this.isFollowRedirect = true;
|
this.isFollowRedirect = true;
|
||||||
this.saveTo = '';
|
this.saveTo = null;
|
||||||
|
|
||||||
|
this.isLoggingCookie = false;
|
||||||
|
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
if (this.engine == "MSXML") {
|
if (this.engine == "MSXML") {
|
||||||
|
@ -406,6 +408,11 @@ var HTTPObject = function(engine) {
|
||||||
cmd.push(this.evaluate(this.cookie));
|
cmd.push(this.evaluate(this.cookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isLoggingCookie) {
|
||||||
|
cmd.push("-c");
|
||||||
|
cmd.push("/tmp/cookie.txt");
|
||||||
|
}
|
||||||
|
|
||||||
cmd.push("-A");
|
cmd.push("-A");
|
||||||
cmd.push((this.userAgent != null ? this.userAgent : ''));
|
cmd.push((this.userAgent != null ? this.userAgent : ''));
|
||||||
|
|
||||||
|
@ -456,8 +463,10 @@ var HTTPObject = function(engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it is download
|
// if it is download
|
||||||
|
if (this.saveTo != null) {
|
||||||
cmd.push("-o");
|
cmd.push("-o");
|
||||||
cmd.push(this.saveTo);
|
cmd.push(this.saveTo);
|
||||||
|
}
|
||||||
|
|
||||||
// set the URL
|
// set the URL
|
||||||
cmd.push(state.url);
|
cmd.push(state.url);
|
||||||
|
@ -668,6 +677,25 @@ var HTTPObject = function(engine) {
|
||||||
return scripts;
|
return scripts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setIsLoggingCookie = function(flag) {
|
||||||
|
this.isLoggingCookie = flag;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getAllCookies = function() {
|
||||||
|
var data = {};
|
||||||
|
|
||||||
|
var rows = splitLn(FILE.readFile("/tmp/cookie.txt"), "utf-8");
|
||||||
|
for (var i = 0; i < rows.length; i++) {
|
||||||
|
var cols = rows[i].split("\t");
|
||||||
|
if (cols.length == 7) {
|
||||||
|
data[cols[5]] = cols[6];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
this.create();
|
this.create();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -683,6 +711,6 @@ exports.get = function(url, data, headers) {
|
||||||
return (new HTTPObject()).setHeaders(headers).setParameters(data).setUseCache(false).get(url).responseBody;
|
return (new HTTPObject()).setHeaders(headers).setParameters(data).setUseCache(false).get(url).responseBody;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.VERSIONINFO = "HTTP Lib (http.js) version 0.5";
|
exports.VERSIONINFO = "HTTP Lib (http.js) version 0.6";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user