mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-11 12:11:04 +00:00
Update http.js
This commit is contained in:
parent
512f0b4cb9
commit
6a13d9437b
36
lib/http.js
36
lib/http.js
|
@ -48,7 +48,9 @@ var HTTPObject = function(engine) {
|
|||
password: ""
|
||||
};
|
||||
this.isFollowRedirect = true;
|
||||
this.saveTo = '';
|
||||
this.saveTo = null;
|
||||
|
||||
this.isLoggingCookie = false;
|
||||
|
||||
this.create = function() {
|
||||
if (this.engine == "MSXML") {
|
||||
|
@ -406,6 +408,11 @@ var HTTPObject = function(engine) {
|
|||
cmd.push(this.evaluate(this.cookie));
|
||||
}
|
||||
|
||||
if (this.isLoggingCookie) {
|
||||
cmd.push("-c");
|
||||
cmd.push("/tmp/cookie.txt");
|
||||
}
|
||||
|
||||
cmd.push("-A");
|
||||
cmd.push((this.userAgent != null ? this.userAgent : ''));
|
||||
|
||||
|
@ -456,8 +463,10 @@ var HTTPObject = function(engine) {
|
|||
}
|
||||
|
||||
// if it is download
|
||||
cmd.push("-o");
|
||||
cmd.push(this.saveTo);
|
||||
if (this.saveTo != null) {
|
||||
cmd.push("-o");
|
||||
cmd.push(this.saveTo);
|
||||
}
|
||||
|
||||
// set the URL
|
||||
cmd.push(state.url);
|
||||
|
@ -668,6 +677,25 @@ var HTTPObject = function(engine) {
|
|||
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();
|
||||
};
|
||||
|
||||
|
@ -683,6 +711,6 @@ exports.get = function(url, data, headers) {
|
|||
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.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user