mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Update har.js
This commit is contained in:
parent
ac2e1117a7
commit
256ca14284
35
lib/har.js
35
lib/har.js
|
@ -15,10 +15,6 @@ var HARObject = function() {
|
|||
this.entryIndex = index;
|
||||
};
|
||||
|
||||
this.addFilter = function(f) {
|
||||
this.filters.push(f);
|
||||
};
|
||||
|
||||
this.load = function(filename) {
|
||||
this.filename = filename;
|
||||
this.data = JSON.parse(FILE.readFile(this.filename, PipeIPC.CdoUTF_8));
|
||||
|
@ -26,22 +22,26 @@ var HARObject = function() {
|
|||
return this;
|
||||
};
|
||||
|
||||
this.play = function(callback) {
|
||||
this.test = function(entry, test) {
|
||||
if (typeof test !== "function")
|
||||
return true;
|
||||
|
||||
try {
|
||||
return test(this, entry, entry.request, entry.response, this.entryIndex);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
this.play = function(callback, test) {
|
||||
var entries = this.data.log.entries;
|
||||
|
||||
while (this.entryIndex < entries.length) {
|
||||
var entry = entries[this.entryIndex];
|
||||
|
||||
var i = 0;
|
||||
while (i < this.filters.length && typeof this.filters[i] === "function") {
|
||||
try {
|
||||
if (!this.filters[i](entry))
|
||||
return;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (this.test(entry, test)) {
|
||||
if (typeof callback !== "function") {
|
||||
console.log(
|
||||
'[' + entry.startedDateTime + ']',
|
||||
|
@ -58,6 +58,7 @@ var HARObject = function() {
|
|||
console.error(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.entryIndex++;
|
||||
}
|
||||
|
@ -74,7 +75,7 @@ var HARObject = function() {
|
|||
|
||||
exports.HARObject = HARObject;
|
||||
|
||||
exports.VERSIONINFO = "HAR(HTTP Archive) manipulate and replay tools version 0.1.4";
|
||||
exports.VERSIONINFO = "HAR(HTTP Archive) manipulate and replay tools version 0.1.5";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user