Update har.js
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run

This commit is contained in:
Namhyeon Go 2024-08-03 17:49:22 +09:00 committed by GitHub
parent ac2e1117a7
commit 256ca14284
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,47 +15,48 @@ var HARObject = function() {
this.entryIndex = index;
};
this.addFilter = function(f) {
this.filters.push(f);
};
this.load = function(filename) {
this.filename = filename;
this.data = JSON.parse(FILE.readFile(this.filename, PipeIPC.CdoUTF_8));
return this;
};
this.test = function(entry, test) {
if (typeof test !== "function")
return true;
this.play = function(callback) {
try {
return test(this, entry, entry.request, entry.response, this.entryIndex);
} catch (e) {
console.warn(e.message);
}
return true;
};
this.play = function(callback, test) {
var entries = this.data.log.entries;
while (this.entryIndex < entries.length) {
var entry = entries[this.entryIndex];
var i = 0;
while (i < this.filters.length && typeof this.filters[i] === "function") {
try {
if (!this.filters[i](entry))
return;
} catch (e) {
console.error(e.message);
}
i++;
}
if (typeof callback !== "function") {
console.log(
'[' + entry.startedDateTime + ']',
'"' + [entry.request.method, entry.request.url, entry.request.httpVersion].join(' ') + '"',
entry.request.url,
entry.request.httpVersion,
entry.response.status,
entry.response.content.size
);
} else {
try {
callback(this, entry, entry.request, entry.response, this.entryIndex);
} catch (e) {
console.error(e.message);
if (this.test(entry, test)) {
if (typeof callback !== "function") {
console.log(
'[' + entry.startedDateTime + ']',
'"' + [entry.request.method, entry.request.url, entry.request.httpVersion].join(' ') + '"',
entry.request.url,
entry.request.httpVersion,
entry.response.status,
entry.response.content.size
);
} else {
try {
callback(this, entry, entry.request, entry.response, this.entryIndex);
} catch (e) {
console.error(e.message);
}
}
}
@ -74,7 +75,7 @@ var HARObject = function() {
exports.HARObject = HARObject;
exports.VERSIONINFO = "HAR(HTTP Archive) manipulate and replay tools version 0.1.4";
exports.VERSIONINFO = "HAR(HTTP Archive) manipulate and replay tools version 0.1.5";
exports.AUTHOR = "abuse@catswords.net";
exports.global = global;
exports.require = require;