I'm using node.js now for almost 2 years for different things. But today was the first time, I wanted to get the 'reasonPhrase' or 'statusMessage' from a clientResponse created using http.request().
There isn't a property I could access. At least there isn't one defined in the docs. Is there a way to get it?
Thanks very much!
It seems like this information is not available thorugh the http-parser that node.js uses.
I've now started a feature request on both node.js and http-parser to implement this.
The following works in node v0.8.x (but not v0.10.x)
var http = require('http');
var clientRequest = http.get("http://www.stackoverflow.com", function(res) {
console.log("statusCode=" + res.statusCode);
});
clientRequest.on('socket', function(socket) {
socket.once('data', function(buffer) {
console.log("reasonPhrase=" + buffer.toString().
match(/^HTTP.+ \d+ (.*)(\n|\r).*/)[1]);
});
});