mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Fix the feedback 2024-04-05 #109
This commit is contained in:
parent
6591ee7074
commit
db5c294ab9
15
lib/file.js
15
lib/file.js
|
@ -168,6 +168,19 @@ function appendFile(FN, content, charset) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// prependFile
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function prependFile(FN, content, charset) {
|
||||
var pipe = PipeIPC.connect("volatile");
|
||||
pipe.setCharset(charset);
|
||||
pipe.startRecorder(FN, PipeIPC.ForWriting);
|
||||
pipe.write(content);
|
||||
pipe.destroy();
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// rotateFile
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -200,7 +213,7 @@ exports.rotateFile = rotateFile;
|
|||
|
||||
exports.CdoCharset = PipeIPC.CdoCharset;
|
||||
|
||||
exports.VERSIONINFO = "File IO Library (file.js) version 0.2.11";
|
||||
exports.VERSIONINFO = "File IO Library (file.js) version 0.2.12";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
51
lib/http.js
51
lib/http.js
|
@ -1,4 +1,5 @@
|
|||
// http.js
|
||||
// Namhyeon Go <abuse@catswords.net>
|
||||
// https://github.com/gnh1201/welsonjs
|
||||
var SYS = require("lib/system");
|
||||
var FILE = require("lib/file");
|
||||
|
@ -71,6 +72,8 @@ var HTTPObject = function(engine) {
|
|||
this.charset = FILE.CdoCharset.CdoUTF_8;
|
||||
this.isUseCharsetDetector = false;
|
||||
|
||||
this.isVerifySSL = true;
|
||||
|
||||
this.create = function() {
|
||||
if (this.engine == "MSXML") {
|
||||
this.interface = CreateObject([
|
||||
|
@ -537,6 +540,15 @@ var HTTPObject = function(engine) {
|
|||
cmd.push(this.saveTo);
|
||||
}
|
||||
|
||||
// If not verify SSL
|
||||
if (!this.isVerifySSL) {
|
||||
if (this.proxy.enabled) {
|
||||
cmd.push("--proxy-insecure");
|
||||
}
|
||||
cmd.push("-k");
|
||||
cmd.push("--ssl-no-revoke");
|
||||
}
|
||||
|
||||
// if the count of this.curlOptions greater than 0
|
||||
if (this.curlOptions.length > 0) {
|
||||
cmd = cmd.concat(this.curlOptions);
|
||||
|
@ -866,8 +878,7 @@ var HTTPObject = function(engine) {
|
|||
"port": 8888,
|
||||
"credential": null
|
||||
};
|
||||
this.curlOptions.push("-k");
|
||||
this.curlOptions.push("--ssl-no-revoke");
|
||||
this.isVerifySSL = false;
|
||||
break;
|
||||
|
||||
case "FIDDLER2": // Fiddler Everywhere
|
||||
|
@ -878,8 +889,7 @@ var HTTPObject = function(engine) {
|
|||
"port": 8866,
|
||||
"credential": null
|
||||
};
|
||||
this.curlOptions.push("-k");
|
||||
this.curlOptions.push("--ssl-no-revoke");
|
||||
this.isVerifySSL = false;
|
||||
break;
|
||||
|
||||
case "MITMPROXY": // mitmproxy
|
||||
|
@ -892,8 +902,7 @@ var HTTPObject = function(engine) {
|
|||
"port": 8080,
|
||||
"credential": null
|
||||
};
|
||||
this.curlOptions.push("-k");
|
||||
this.curlOptions.push("--ssl-no-revoke");
|
||||
this.isVerifySSL = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -985,14 +994,42 @@ function _delete(url, params, headers) {
|
|||
return create().setHeaders(headers).setParameters(params).setUseCache(false)._delete(url).responseBody;
|
||||
}
|
||||
|
||||
function parseURL(input) {
|
||||
var pattern = /^(?:(https?):\/\/)?(?:([^:@]+)(?::([^:@]*))?@)?([^:]+)(?::(\d{1,5}))?$/;
|
||||
var matches = input.match(pattern);
|
||||
if (!matches) return null;
|
||||
|
||||
var protocol = matches[1] || 'http';
|
||||
var username = matches[2] || '';
|
||||
var password = matches[3] || '';
|
||||
var host = matches[4];
|
||||
var port = matches[5] || '';
|
||||
var credential = null;
|
||||
|
||||
if (username != '' && password != '') {
|
||||
credential = {
|
||||
"username": username,
|
||||
"password": password
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"protocol": protocol,
|
||||
"host": host,
|
||||
"port": parseInt(port),
|
||||
"credential": credential
|
||||
};
|
||||
}
|
||||
|
||||
exports.create = create;
|
||||
exports.get = get;
|
||||
exports.post = post;
|
||||
exports.patch = patch;
|
||||
exports.put = put;
|
||||
exports._delete = _delete;
|
||||
exports.parseURL = parseURL;
|
||||
|
||||
exports.VERSIONINFO = "HTTP request module (http.js) version 0.7.12";
|
||||
exports.VERSIONINFO = "HTTP request module (http.js) version 0.7.13";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
|
@ -146,6 +146,7 @@ function PipeIPC() {
|
|||
this.lastReadTime = -1;
|
||||
this.lastWriteTime = -1;
|
||||
this.maxSentences = 0;
|
||||
this.recorder_iomode = ForAppending;
|
||||
|
||||
this.getCurrentTime = function() {
|
||||
return new Date().getTime();
|
||||
|
@ -222,19 +223,22 @@ function PipeIPC() {
|
|||
|
||||
this.savefile = filename;
|
||||
this.tmpfile = this.savefile + ".tmp";
|
||||
this.recorder_iomode = iomode;
|
||||
|
||||
// read a text from save file
|
||||
var isExistsSaveFile = checkFileExists(this.savefile);
|
||||
var isExistsTmpFile = checkFileExists(this.tmpfile);
|
||||
while (isExistsSaveFile && !isExistsTmpFile) {
|
||||
try {
|
||||
var fso = openTextFile(this.tmpfile, ForWriting);
|
||||
fso.Write(this.readTextFromFile(this.savefile));
|
||||
fso.Close();
|
||||
isExistsTmpFile = checkFileExists(this.tmpfile);
|
||||
} catch (e) {
|
||||
isExistsTmpFile = false;
|
||||
this.waitForRetry();
|
||||
if (this.recorder_iomode == ForAppending) {
|
||||
var isExistsSaveFile = checkFileExists(this.savefile);
|
||||
var isExistsTmpFile = checkFileExists(this.tmpfile);
|
||||
while (isExistsSaveFile && !isExistsTmpFile) {
|
||||
try {
|
||||
var fso = openTextFile(this.tmpfile, ForWriting);
|
||||
fso.Write(this.readTextFromFile(this.savefile));
|
||||
fso.Close();
|
||||
isExistsTmpFile = checkFileExists(this.tmpfile);
|
||||
} catch (e) {
|
||||
isExistsTmpFile = false;
|
||||
this.waitForRetry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,14 +299,18 @@ function PipeIPC() {
|
|||
};
|
||||
|
||||
this._record = function(message) {
|
||||
this.recorder.Write(message);
|
||||
if (this.recorder_iomode == ForAppending) {
|
||||
this.recorder.Write(message);
|
||||
} else if (this.recorder_iomode == ForWriting) {
|
||||
this.recorder.Write(message + this.delimiter + this.readTextFromFile(this.savefile));
|
||||
}
|
||||
};
|
||||
|
||||
this.record = function(message) {
|
||||
var isRecorded = false;
|
||||
while (!isRecorded) {
|
||||
try {
|
||||
this.openRecorder();
|
||||
this.openRecorder(this.recorder_iomode);
|
||||
this._record(message);
|
||||
this.closeRecorder();
|
||||
this.commit(this.savefile);
|
||||
|
|
Loading…
Reference in New Issue
Block a user