Skip to content

Commit

Permalink
fixed httpTracker to emit the correct data
Browse files Browse the repository at this point in the history
  • Loading branch information
joeferner committed Jan 16, 2012
1 parent 811598b commit ff1580d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 8 additions & 1 deletion examples/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ pcapparser.on('globalHeader', function(globalHeader) {
pcapparser.on('packet', function (rawPacket) {
var packet = dissector.dissect(rawPacket);
evalFields(packet);
//tcpTracker.track(packet);
tcpTracker.track(packet);
});

httpTracker.on('responseData', function (http, buffer) {
//console.log(http);
evalFields(http);
for(var i=0; i<argv.field.length; i++) {
var f = argv.field[i];
if(f == 'responseData' && buffer) {
console.log(buffer.toString());
}
}
});

pcapparser.parse();
Expand Down
8 changes: 5 additions & 3 deletions lib/httpTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ HttpTracker.prototype._onPacket = function(session, packet) {
if(httpTrackerSession && packet.http && packet.http.response && packet.http.response.value == 1) {
this._populateRequestOrResponse(httpTrackerSession.response, packet);
this.emit("responseHeaders", httpTrackerSession);
var data;
if(packet["data-text-lines"]) {
this.emit("responseData", httpTrackerSession, packet["data-text-lines"]);
} else {
this.emit("responseData", httpTrackerSession);
data = packet["data-text-lines"].rawData;
}
this.emit("responseData", httpTrackerSession, data);
}
}

Expand Down Expand Up @@ -103,5 +103,7 @@ HttpTracker.prototype._headerKeyToDisplay = function(key) {
if(key == 'last_modified') return 'Last-Modified';
if(key == 'content_length_header') return 'Content-Length';
if(key == 'content_type') return 'Content-Type';
if(key == 'cache_control') return 'Cache-Control';
if(key == 'set_cookie') return 'Set-Cookie';
return key;
}
7 changes: 5 additions & 2 deletions lib/nodeShark.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ exports.Dissector.prototype.dissect = function() {

exports.isStandardKey = function(key) {
if(key == "sizeInPacket") return true;
if(key == "posInPacket") return true;
if(key == "showValue") return true;
if(key == "positionInPacket") return true;
if(key == "abbreviation") return true;
if(key == "value") return true;
if(key == "dataSource") return true;
if(key == "rawData") return true;
if(key == "text") return true;
return false;
}

0 comments on commit ff1580d

Please sign in to comment.