Skip to content

Commit

Permalink
fix #144
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 committed Sep 25, 2024
1 parent ed3b631 commit 266971f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
1 change: 1 addition & 0 deletions data/example_domains.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example.org
1 change: 1 addition & 0 deletions data/example_urls.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 4 additions & 2 deletions examples/certchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var HTTP = require("lib/http");
var RAND = require("lib/rand");

function main() {
var domains = splitLn(FILE.readFile("data\\target_domains.txt", FILE.CdoCharset.CdoUTF_8));
var domains = splitLn(FILE.readFile("data\\example_domains.txt", FILE.CdoCharset.CdoUTF_8));
var urls = [];

domains.forEach(function(x) {
Expand All @@ -17,6 +17,8 @@ function main() {
.setConnectTimeout(2)
.open("GET", "https://" + x)
.send();

console.log(handler.responseText);

if (handler.detectSSLCompleted()) {
urls.push("https://" + x);
Expand All @@ -29,7 +31,7 @@ function main() {
sleep(RAND.getInt(1000, 2000));
});

FILE.writeFile("data\\target_urls.txt", urls.join("\r\n"), FILE.CdoCharset.CdoUTF_8);
FILE.writeFile("data\\example_urls.txt", urls.join("\r\n"), FILE.CdoCharset.CdoUTF_8);

console.log("Done");
}
Expand Down
7 changes: 5 additions & 2 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ var HTTPObject = function(engine) {
]);
} else if (this.engine == "CURL") {
this._interface = SHELL.create();
this.setBinPath("bin\\curl.exe"); // the location of cURL binary
this.setBinPath("bin\\x64\\curl-8.10.1_1-win64-mingw\\bin\\curl.exe"); // the location of cURL binary
} else if (this.engine == "BITS") {
this._interface = SHELL.create();
this.setBinPath("bitsadmin.exe"); // the location of BITS binary
Expand Down Expand Up @@ -701,6 +701,9 @@ var HTTPObject = function(engine) {
// Get debuging text
debuggingText = this._interface.stderr.read();
}

// clear the stdout and stderr
this._interface.clear();
} else if (this.engine == "BITS") {
var job_name = "welsonjs_" + PipeIPC.UUIDv4.create().substring(0, 8);
var job_priority = "normal";
Expand Down Expand Up @@ -1155,7 +1158,7 @@ exports.parseURL = parseURL;
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
exports.defaultUserAgent = DEFAULT_USER_AGENT; // compatible

exports.VERSIONINFO = "HTTP REST Client (http.js) version 0.7.30";
exports.VERSIONINFO = "HTTP REST Client (http.js) version 0.7.31";
exports.AUTHOR = "[email protected]";
exports.global = global;
exports.require = global.require;
18 changes: 10 additions & 8 deletions lib/pipe-ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,15 @@ function PipeIPC() {
};

this.read = function() {
var isRead = false;
var isReadCompleted = false;
var text = '';

while (!isRead) {
while (!isReadCompleted) {
try {
this.openReader();
text += this._read(this.reader);
isRead = true;
isReadCompleted = true;

this.lastReadTime = this.getCurrentTime();
this.closeReader();
} catch (e) {
Expand Down Expand Up @@ -488,19 +489,19 @@ function PipeIPC() {

var isFileExists = checkFileExists(filename);
if (isFileExists) {
var isRead = false;
while (!isRead) {
var isReadCompleted = false;
while (!isReadCompleted) {
try {
var ado = makeInterface(1);
ado.Charset = charset;
ado.Open();
ado.LoadFromFile(filename);
text += ado.ReadText();
ado.Close();
isRead = true;
isReadCompleted = true;
} catch (e) {
//console.log(e.message);
isRead = false;
isReadCompleted = false;
}
}
} else {
Expand All @@ -513,7 +514,8 @@ function PipeIPC() {
this.loadFromFile = function(filename, charset) {
charset = (typeof charset !== "undefined" ? charset : this.charset);

this.write(this.readTextFromFile(filename, charset), ForWriting);
var text = this.readTextFromFile(filename, charset);
this.write(text, ForWriting);
};

this.reload = function(charset) {
Expand Down
12 changes: 7 additions & 5 deletions lib/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,13 @@ var ShellObject = function() {
this.stderr.reload(this.charset);

stdout = this.stdout.read();
stderr = this.stderr.read();
//stderr = this.stderr.read();

//stdout = this.stdout.read();
//stderr = this.stderr.read();
//console.log("[stdout] " + stdout);
//console.log("[stderr] " + stderr);

this.stdout.destroy();
this.stderr.destroy();

return stdout;
};

Expand Down Expand Up @@ -171,6 +168,11 @@ var ShellObject = function() {
this._interface = null;
};

this.clear = function() {
this.stdout.destroy();
this.stderr.destroy();
};

this.create();
};

Expand Down Expand Up @@ -222,7 +224,7 @@ exports.getPathOfMyDocuments = function() {

exports.CdoCharset = PipeIPC.CdoCharset;

exports.VERSIONINFO = "Windows Shell Interface (shell.js) version 0.3.13";
exports.VERSIONINFO = "Windows Shell Interface (shell.js) version 0.3.14";
exports.AUTHOR = "[email protected]";
exports.global = global;
exports.require = global.require;

0 comments on commit 266971f

Please sign in to comment.