mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-11 16:35:13 +00:00
Update har.js
This commit is contained in:
parent
aeef44d3d9
commit
5ff6680cee
31
lib/har.js
31
lib/har.js
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user