Update har.js

This commit is contained in:
Namhyeon Go 2024-08-03 16:41:36 +09:00 committed by GitHub
parent aeef44d3d9
commit 5ff6680cee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,7 @@ var FILE = require("lib/file");
var HARObject = function() {
this.filename = null;
this.data = null;
this.data = {};
this.entryIndex = 0;
this.onEntry = null;
@ -19,23 +19,28 @@ var HARObject = function() {
this.load = function(filename) {
this.filename = filename;
this.data = JSON.parse(FILE.readFile(filename, PipeIPC.CdoUTF_8));
this.data = JSON.parse(FILE.readFile(this.filename, PipeIPC.CdoUTF_8));
return this;
};
this.play = function(onEntry) {
if (this.data = null)
return;
var entries = this.data.entries;
this.play = function() {
var entries = this.data.log.entries;
while (this.entryIndex < entries.length) {
var entry = this.data.entries[entryIndex];
var entry = entries[this.entryIndex];
if (typeof this.onEntry !== "function") {
console.log(entry.request.httpVersion, entry.request.method, entry.response.status, entry.request.url);
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 {
this.onEntry(this, entry, entry.request, entry.response);
this.onEntry(this, entry, entry.request, entry.response, this.entryIndex);
} catch (e) {
console.error(e.message);
}
@ -43,16 +48,20 @@ var HARObject = function() {
this.entryIndex++;
}
return this;
};
this.rewind = function() {
this.entryIndex = 0;
return this;
};
};
exports.HARObject = HARObject;
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1.1";
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1.2";
exports.AUTHOR = "abuse@catswords.net";
exports.global = global;
exports.require = require;