mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-06-18 02:59:04 +00:00
Update har.js
This commit is contained in:
parent
5ff6680cee
commit
92e611f49a
12
lib/har.js
12
lib/har.js
|
@ -13,10 +13,6 @@ var HARObject = function() {
|
||||||
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;
|
||||||
this.data = JSON.parse(FILE.readFile(this.filename, PipeIPC.CdoUTF_8));
|
this.data = JSON.parse(FILE.readFile(this.filename, PipeIPC.CdoUTF_8));
|
||||||
|
@ -24,12 +20,12 @@ var HARObject = function() {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.play = function() {
|
this.play = function(callback) {
|
||||||
var entries = this.data.log.entries;
|
var entries = this.data.log.entries;
|
||||||
while (this.entryIndex < entries.length) {
|
while (this.entryIndex < entries.length) {
|
||||||
var entry = entries[this.entryIndex];
|
var entry = entries[this.entryIndex];
|
||||||
|
|
||||||
if (typeof this.onEntry !== "function") {
|
if (typeof callback !== "function") {
|
||||||
console.log(
|
console.log(
|
||||||
'[' + entry.startedDateTime + ']',
|
'[' + entry.startedDateTime + ']',
|
||||||
'"' + [entry.request.method, entry.request.url, entry.request.httpVersion].join(' ') + '"',
|
'"' + [entry.request.method, entry.request.url, entry.request.httpVersion].join(' ') + '"',
|
||||||
|
@ -40,7 +36,7 @@ var HARObject = function() {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
this.onEntry(this, entry, entry.request, entry.response, this.entryIndex);
|
callback(this, entry, entry.request, entry.response, this.entryIndex);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +57,7 @@ var HARObject = function() {
|
||||||
|
|
||||||
exports.HARObject = HARObject;
|
exports.HARObject = HARObject;
|
||||||
|
|
||||||
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1.2";
|
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1.3";
|
||||||
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