Created
October 9, 2012 22:37
-
-
Save nlf/3861903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
fs = require('fs'); | |
var data = fs.readFileSync('./sample_request.txt'); | |
var parser = http.parsers.alloc(); | |
parser.reinitialize(1); | |
console.log(parser); | |
parser.onIncoming = function (res) { | |
console.log('onIncoming:', res); | |
res.on('data', function (data) { | |
console.log('data:', data.toString()); | |
}); | |
}; | |
parser.onMessageComplete = function () { | |
console.log('onMessageComplete:', arguments); | |
}; | |
var ret = parser.execute(data, 0, data.length); | |
console.log('EXECUTE:', ret); | |
parser.finish(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment