mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 13:16:05 +00:00
Update http.js
This commit is contained in:
parent
2912ca8b4b
commit
cbac701e7e
17
lib/http.js
17
lib/http.js
|
@ -1,5 +1,5 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// HTTP API
|
||||
// HTTP API with PIPE-IPC
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
var SYS = require("lib/system");
|
||||
var FILE = require("lib/file");
|
||||
|
@ -10,7 +10,6 @@ var BASE64 = require("lib/base64");
|
|||
var OS_NAME = SYS.getOS();
|
||||
var OS_ARCH = SYS.getArch();
|
||||
var DEVICE_UUID = SYS.getUUID();
|
||||
var SEED = RAND.getSeed();
|
||||
|
||||
var HTTPObject = function(engine) {
|
||||
this.interface = null;
|
||||
|
@ -21,7 +20,7 @@ var HTTPObject = function(engine) {
|
|||
this.headers = {};
|
||||
this.parameters = {};
|
||||
this.dataType = null;
|
||||
this.userAgent = "WelsonJS/0.2.4-dev (" + OS_NAME + "; " + OS_ARCH + "; " + DEVICE_UUID + "; https://catswords.social/@catswords_oss; abuse@catswords.net)";
|
||||
this.userAgent = "WelsonJS/0.2.7-dev (" + OS_NAME + "; " + OS_ARCH + "; " + DEVICE_UUID + "; https://catswords.social/@catswords_oss; abuse@catswords.net)";
|
||||
this.isAsynchronous = false;
|
||||
this.proxy = {
|
||||
"enabled": false,
|
||||
|
@ -33,6 +32,7 @@ var HTTPObject = function(engine) {
|
|||
this.engine = (typeof(engine) !== "undefined" ? engine : "MSXML");
|
||||
|
||||
this.cookie = null;
|
||||
this.storedCookie = PipeIPC.create("volatile");
|
||||
this.states = [];
|
||||
this.variables = {
|
||||
"uuidv4": RAND.uuidv4,
|
||||
|
@ -446,7 +446,7 @@ var HTTPObject = function(engine) {
|
|||
|
||||
if (this.isLoggingCookie) {
|
||||
cmd.push("-c");
|
||||
cmd.push("tmp/cookie_" + SEED + ".txt");
|
||||
cmd.push(this.storedCookie.path);
|
||||
}
|
||||
|
||||
cmd.push("-A");
|
||||
|
@ -521,6 +521,11 @@ var HTTPObject = function(engine) {
|
|||
// Get response text
|
||||
responseText = this.interface.setCharset(this.charset).exec(cmd);
|
||||
|
||||
// Reload a cookie in the pipe
|
||||
if (this.isLoggingCookie) {
|
||||
this.storedCookie.reload();
|
||||
}
|
||||
|
||||
// If enabled the charset(text encoding) detector
|
||||
if (this.isUseCharsetDetector) {
|
||||
var detectedCharset = this.detectCharset(responseText);
|
||||
|
@ -780,7 +785,7 @@ var HTTPObject = function(engine) {
|
|||
this.getAllCookies = function() {
|
||||
var data = {};
|
||||
|
||||
var rows = splitLn(FILE.readFile("tmp/cookie_" + SEED + ".txt"), "utf-8");
|
||||
var rows = splitLn(this.storedCookie.read());
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var cols = rows[i].split("\t");
|
||||
if (cols.length == 7) {
|
||||
|
@ -960,7 +965,7 @@ exports.patch = patch;
|
|||
exports.put = put;
|
||||
exports._delete = _delete;
|
||||
|
||||
exports.VERSIONINFO = "HTTP Lib (http.js) version 0.7.7";
|
||||
exports.VERSIONINFO = "HTTP Library (http.js) version 0.7.8";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user