Update har.js

This commit is contained in:
Namhyeon Go 2024-08-03 15:51:47 +09:00 committed by GitHub
parent c6cbe96e03
commit 2e8c530ba9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,10 +6,15 @@ var HARObject = function() {
this.filename = null;
this.data = null;
this.entryIndex = 0;
this.onEntry = null;
this.setEntryIndex = function(index) {
this.entryIndex = index;
};
this.setOnEntry = function(callback) {
this.onEntry = callback;
};
this.load = function(filename) {
this.filename = filename;
@ -17,7 +22,7 @@ var HARObject = function() {
return this;
};
this.walk = function(onEntry) {
this.play = function(onEntry) {
if (this.data = null)
return;
@ -25,20 +30,28 @@ var HARObject = function() {
while (this.entryIndex < entries.length) {
var entry = this.data.entries[entryIndex];
try {
onEntry(this, entry, entry.request, entry.response);
} catch (e) {
console.error(e.message);
if (typeof this.onEntry !== "function") {
console.log(entry.request.httpVersion, entry.request.method, entry.response.status, entry.request.url);
} else {
try {
this.onEntry(this, entry, entry.request, entry.response);
} catch (e) {
console.error(e.message);
}
}
this.entryIndex++;
}
};
this.rewind = function() {
this.entryIndex = 0;
};
};
exports.HARObject = HARObject;
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1";
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1.1";
exports.AUTHOR = "abuse@catswords.net";
exports.global = global;
exports.require = require;