Update http.js

This commit is contained in:
Namhyeon Go 2022-05-30 20:19:46 +09:00 committed by GitHub
parent 5a2bf30b38
commit b93cac5e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ var HTTPObject = function(engine) {
"protocol": "http", "protocol": "http",
"host": "127.0.0.1", "host": "127.0.0.1",
"port": 80, "port": 80,
"credential": null // { username: "user", password: "pass" } "credential": null // { username: "user", password: "pass" }
}; };
this.engine = (typeof(engine) !== "undefined" ? engine : "MSXML"); this.engine = (typeof(engine) !== "undefined" ? engine : "MSXML");
@ -35,14 +35,14 @@ var HTTPObject = function(engine) {
this.states = []; this.states = [];
this.variables = { this.variables = {
"uuidv4": RAND.uuidv4, "uuidv4": RAND.uuidv4,
"base64json": function(v) { // e.g. {base64json VARIABLE_NAME} "base64json": function(v) { // e.g. {base64json VARIABLE_NAME}
return BASE64.encode(JSON.stringify(v)); return BASE64.encode(JSON.stringify(v));
}, },
"unixnow": function(diff) { // e.g. {unixnow -300} (seconds) "unixnow": function(diff) { // e.g. {unixnow -300} (seconds)
var t = parseInt(diff); var t = parseInt(diff);
return Math.floor(new Date().getTime() / 1000) - t; return Math.floor(new Date().getTime() / 1000) - t;
}, },
"unixnowms": function(diff) { // e.g. {unixnowms -300000} (milliseconds) "unixnowms": function(diff) { // e.g. {unixnowms -300000} (milliseconds)
var t = parseInt(diff); var t = parseInt(diff);
return Math.floor(new Date().getTime()) - t; return Math.floor(new Date().getTime()) - t;
} }
@ -60,7 +60,7 @@ var HTTPObject = function(engine) {
this.isLoggingCookie = false; this.isLoggingCookie = false;
this.debuggingText = ''; this.debuggingText = '';
this.curlOptions = []; this.curlOptions = [];
this.create = function() { this.create = function() {
if (this.engine == "MSXML") { if (this.engine == "MSXML") {
@ -329,9 +329,9 @@ var HTTPObject = function(engine) {
this.open = function(method, url) { this.open = function(method, url) {
var url = this.serializeParameters(url); var url = this.serializeParameters(url);
this.setMethod(method.toUpperCase()); // set method this.setMethod(method.toUpperCase()); // set method
this.pushState(null, null, url); // push state this.pushState(null, null, url); // push state
this.setHeader("User-Agent", (this.userAgent != null ? this.evaluate(this.userAgent) : '')); // user agent this.setHeader("User-Agent", (this.userAgent != null ? this.evaluate(this.userAgent) : '')); // user agent
try { try {
if (this.engine == "MSXML") { if (this.engine == "MSXML") {
@ -598,8 +598,7 @@ var HTTPObject = function(engine) {
try { try {
var variables = (typeof(variables) !== "undefined") ? variables : {}; var variables = (typeof(variables) !== "undefined") ? variables : {};
for (var k in variables) for (var k in variables)
this.setVariable(k, variables[k]) this.setVariable(k, variables[k]);
;
} catch (e) { } catch (e) {
console.error("HTTPObject.setVariables() ->", e.message); console.error("HTTPObject.setVariables() ->", e.message);
} }
@ -610,7 +609,10 @@ var HTTPObject = function(engine) {
var str = String(str); var str = String(str);
var Lpos = str.indexOf('{'); var Lpos = str.indexOf('{');
var Rpos = str.indexOf('}', Lpos + 1); var Rpos = str.indexOf('}', Lpos + 1);
var s0 = '', s1 = [], s2 = null, s3, s4; var s0 = '',
s1 = [],
s2 = null,
s3, s4;
while (Lpos > -1 && Rpos > -1) { while (Lpos > -1 && Rpos > -1) {
s0 = str.substring(Lpos + 1, Rpos); s0 = str.substring(Lpos + 1, Rpos);
@ -750,7 +752,7 @@ var HTTPObject = function(engine) {
console.warn("Existing proxy settings will be reset."); console.warn("Existing proxy settings will be reset.");
switch(_debugger) { switch (_debugger) {
case "FIDDLER": case "FIDDLER":
this.proxy = { this.proxy = {
"enabled": true, "enabled": true,