mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 05:31: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.filename = null;
|
||||||
this.data = null;
|
this.data = null;
|
||||||
this.entryIndex = 0;
|
this.entryIndex = 0;
|
||||||
|
this.onEntry = null;
|
||||||
|
|
||||||
this.setEntryIndex = function(index) {
|
this.setEntryIndex = function(index) {
|
||||||
this.entryIndex = index;
|
this.entryIndex = index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setOnEntry = function(callback) {
|
||||||
|
this.onEntry = callback;
|
||||||
|
};
|
||||||
|
|
||||||
this.load = function(filename) {
|
this.load = function(filename) {
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
|
@ -17,7 +22,7 @@ var HARObject = function() {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.walk = function(onEntry) {
|
this.play = function(onEntry) {
|
||||||
if (this.data = null)
|
if (this.data = null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -25,20 +30,28 @@ var HARObject = function() {
|
||||||
while (this.entryIndex < entries.length) {
|
while (this.entryIndex < entries.length) {
|
||||||
var entry = this.data.entries[entryIndex];
|
var entry = this.data.entries[entryIndex];
|
||||||
|
|
||||||
try {
|
if (typeof this.onEntry !== "function") {
|
||||||
onEntry(this, entry, entry.request, entry.response);
|
console.log(entry.request.httpVersion, entry.request.method, entry.response.status, entry.request.url);
|
||||||
} catch (e) {
|
} else {
|
||||||
console.error(e.message);
|
try {
|
||||||
|
this.onEntry(this, entry, entry.request, entry.response);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entryIndex++;
|
this.entryIndex++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.rewind = function() {
|
||||||
|
this.entryIndex = 0;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.HARObject = HARObject;
|
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.AUTHOR = "abuse@catswords.net";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = require;
|
exports.require = require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user