Gavriel
Gavriel

Reputation: 19247

How can I get the http request headers actually sent by me in node.js http request

Here's my simplified code:

var request = http.request(options);
request.on('response', function( res ) {
    console.log("response received");
});
request.end();

I would like to print out the actually sent request headers (I assume that node adds some itself) How can I get them?

Upvotes: 2

Views: 142

Answers (1)

glenschler
glenschler

Reputation: 188

It lives in the request object, which can be found in the response res.req._header. It's helpful to use node-inspector to inspect these objects in real time.

request.on('response', function( res ) {
  console.log(res.req._header);
  console.log("response received");
});

Upvotes: 3

Related Questions