mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-11 20:21:03 +00:00
Update har.js
This commit is contained in:
parent
c6cbe96e03
commit
2e8c530ba9
25
lib/har.js
25
lib/har.js
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user