Fix the feedback 2024-04-05 #109

This commit is contained in:
Namhyeon Go 2024-04-06 20:26:07 +09:00
parent 6591ee7074
commit db5c294ab9
3 changed files with 79 additions and 21 deletions

View File

@ -168,6 +168,19 @@ function appendFile(FN, content, charset) {
return result; 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 // rotateFile
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@ -200,7 +213,7 @@ exports.rotateFile = rotateFile;
exports.CdoCharset = PipeIPC.CdoCharset; 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.AUTHOR = "abuse@catswords.net";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;

View File

@ -1,4 +1,5 @@
// http.js // http.js
// Namhyeon Go <abuse@catswords.net>
// https://github.com/gnh1201/welsonjs // https://github.com/gnh1201/welsonjs
var SYS = require("lib/system"); var SYS = require("lib/system");
var FILE = require("lib/file"); var FILE = require("lib/file");
@ -71,6 +72,8 @@ var HTTPObject = function(engine) {
this.charset = FILE.CdoCharset.CdoUTF_8; this.charset = FILE.CdoCharset.CdoUTF_8;
this.isUseCharsetDetector = false; this.isUseCharsetDetector = false;
this.isVerifySSL = true;
this.create = function() { this.create = function() {
if (this.engine == "MSXML") { if (this.engine == "MSXML") {
this.interface = CreateObject([ this.interface = CreateObject([
@ -537,6 +540,15 @@ var HTTPObject = function(engine) {
cmd.push(this.saveTo); 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 the count of this.curlOptions greater than 0
if (this.curlOptions.length > 0) { if (this.curlOptions.length > 0) {
cmd = cmd.concat(this.curlOptions); cmd = cmd.concat(this.curlOptions);
@ -866,8 +878,7 @@ var HTTPObject = function(engine) {
"port": 8888, "port": 8888,
"credential": null "credential": null
}; };
this.curlOptions.push("-k"); this.isVerifySSL = false;
this.curlOptions.push("--ssl-no-revoke");
break; break;
case "FIDDLER2": // Fiddler Everywhere case "FIDDLER2": // Fiddler Everywhere
@ -878,8 +889,7 @@ var HTTPObject = function(engine) {
"port": 8866, "port": 8866,
"credential": null "credential": null
}; };
this.curlOptions.push("-k"); this.isVerifySSL = false;
this.curlOptions.push("--ssl-no-revoke");
break; break;
case "MITMPROXY": // mitmproxy case "MITMPROXY": // mitmproxy
@ -892,8 +902,7 @@ var HTTPObject = function(engine) {
"port": 8080, "port": 8080,
"credential": null "credential": null
}; };
this.curlOptions.push("-k"); this.isVerifySSL = false;
this.curlOptions.push("--ssl-no-revoke");
break; break;
default: default:
@ -985,14 +994,42 @@ function _delete(url, params, headers) {
return create().setHeaders(headers).setParameters(params).setUseCache(false)._delete(url).responseBody; 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.create = create;
exports.get = get; exports.get = get;
exports.post = post; exports.post = post;
exports.patch = patch; exports.patch = patch;
exports.put = put; exports.put = put;
exports._delete = _delete; 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.AUTHOR = "abuse@catswords.net";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;

View File

@ -146,6 +146,7 @@ function PipeIPC() {
this.lastReadTime = -1; this.lastReadTime = -1;
this.lastWriteTime = -1; this.lastWriteTime = -1;
this.maxSentences = 0; this.maxSentences = 0;
this.recorder_iomode = ForAppending;
this.getCurrentTime = function() { this.getCurrentTime = function() {
return new Date().getTime(); return new Date().getTime();
@ -222,8 +223,10 @@ function PipeIPC() {
this.savefile = filename; this.savefile = filename;
this.tmpfile = this.savefile + ".tmp"; this.tmpfile = this.savefile + ".tmp";
this.recorder_iomode = iomode;
// read a text from save file // read a text from save file
if (this.recorder_iomode == ForAppending) {
var isExistsSaveFile = checkFileExists(this.savefile); var isExistsSaveFile = checkFileExists(this.savefile);
var isExistsTmpFile = checkFileExists(this.tmpfile); var isExistsTmpFile = checkFileExists(this.tmpfile);
while (isExistsSaveFile && !isExistsTmpFile) { while (isExistsSaveFile && !isExistsTmpFile) {
@ -237,6 +240,7 @@ function PipeIPC() {
this.waitForRetry(); this.waitForRetry();
} }
} }
}
// open a recorder // open a recorder
this.openRecorder(iomode); this.openRecorder(iomode);
@ -295,14 +299,18 @@ function PipeIPC() {
}; };
this._record = function(message) { this._record = function(message) {
if (this.recorder_iomode == ForAppending) {
this.recorder.Write(message); this.recorder.Write(message);
} else if (this.recorder_iomode == ForWriting) {
this.recorder.Write(message + this.delimiter + this.readTextFromFile(this.savefile));
}
}; };
this.record = function(message) { this.record = function(message) {
var isRecorded = false; var isRecorded = false;
while (!isRecorded) { while (!isRecorded) {
try { try {
this.openRecorder(); this.openRecorder(this.recorder_iomode);
this._record(message); this._record(message);
this.closeRecorder(); this.closeRecorder();
this.commit(this.savefile); this.commit(this.savefile);