console.log("Before END")
console.log("'res' object:" ,res)
var mydate=res.get("date") //Doing var mydate=res.getHeader("date") is the same
console.log(mydate)
res.end()
console.log("After END")
console.log("'res' object" ,res)
})
app.listen(4000)
And the output is:
Before END
'res' object: { domain: null,
_events: { prefinish: [Function: resOnFinish] },
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_removedHeader: {},
_hasBody: true,
_trailer: '',
finished: false,
_hangupClose: false,
socket:
{ _connecting: false,
_hadError: false,
_handle:
{ fd: 12,
reading: true,
owner: [Circular],
onread: [Function: onread],
onconnection: null,
writeQueueSize: 0 },
_host: null,
_readableState:
{ objectMode: false,
highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: false,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null,
resumeScheduled: false },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
drain: [Object],
timeout: [Function],
error: [Function: socketOnError],
close: [Object],
data: [Function: socketOnData] },
_maxListeners: undefined,
_writableState:
{ objectMode: false,
highWaterMark: 16384,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [],
pendingcb: 0,
prefinished: false,
errorEmitted: false },
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server:
{ domain: null,
_events: [Object],
_maxListeners: undefined,
_connections: 1,
connections: [Getter/Setter],
_handle: [Object],
_usingSlaves: false,
_slaves: [],
allowHalfOpen: true,
httpAllowHalfOpen: false,
timeout: 120000,
_connectionKey: '4:null:4000' },
_idleTimeout: 120000,
_idleNext: { _idleNext: [Circular], _idlePrev: [Circular] },
_idlePrev: { _idleNext: [Circular], _idlePrev: [Circular] },
_idleStart: 2042255,
parser:
{ '0': [Function: parserOnHeaders],
'1': [Function: parserOnHeadersComplete],
'2': [Function: parserOnBody],
'3': [Function: parserOnMessageComplete],
_headers: [],
_url: '',
socket: [Circular],
incoming: [Object],
maxHeaderPairs: 2000,
onIncoming: [Function: parserOnIncoming] },
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Circular] },
connection:
{ _connecting: false,
_hadError: false,
_handle:
{ fd: 12,
reading: true,
owner: [Circular],
onread: [Function: onread],
onconnection: null,
writeQueueSize: 0 },
_host: null,
_readableState:
{ objectMode: false,
highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: false,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null,
resumeScheduled: false },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
drain: [Object],
timeout: [Function],
error: [Function: socketOnError],
close: [Object],
data: [Function: socketOnData] },
_maxListeners: undefined,
_writableState:
{ objectMode: false,
highWaterMark: 16384,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [],
pendingcb: 0,
prefinished: false,
errorEmitted: false },
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server:
{ domain: null,
_events: [Object],
_maxListeners: undefined,
_connections: 1,
connections: [Getter/Setter],
_handle: [Object],
_usingSlaves: false,
_slaves: [],
allowHalfOpen: true,
httpAllowHalfOpen: false,
timeout: 120000,
_connectionKey: '4:null:4000' },
_idleTimeout: 120000,
_idleNext: { _idleNext: [Circular], _idlePrev: [Circular] },
_idlePrev: { _idleNext: [Circular], _idlePrev: [Circular] },
_idleStart: 2042255,
parser:
{ '0': [Function: parserOnHeaders],
'1': [Function: parserOnHeadersComplete],
'2': [Function: parserOnBody],
'3': [Function: parserOnMessageComplete],
_headers: [],
_url: '',
socket: [Circular],
incoming: [Object],
maxHeaderPairs: 2000,
onIncoming: [Function: parserOnIncoming] },
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Circular] },
_headers: { 'x-powered-by': 'Express' },
_headerNames: { 'x-powered-by': 'X-Powered-By' },
req:
{ _readableState:
{ objectMode: false,
highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events: {},
_maxListeners: undefined,
socket:
{ _connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 2042255,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Circular] },
connection:
{ _connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 2042255,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Circular] },
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: false,
headers:
{ host: '
127.0.0.1:4000',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'accept-language': 'ca,en-us;q=0.7,en;q=0.3',
'accept-encoding': 'gzip, deflate',
connection: 'keep-alive',
'cache-control': 'max-age=0' },
rawHeaders:
[ 'Host',
'
127.0.0.1:4000',
'User-Agent',
'Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0',
'Accept',
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language',
'ca,en-us;q=0.7,en;q=0.3',
'Accept-Encoding',
'gzip, deflate',
'Connection',
'keep-alive',
'Cache-Control',
'max-age=0' ],
trailers: {},
rawTrailers: [],
_pendings: [],
_pendingIndex: 0,
upgrade: false,
url: '/',
method: 'GET',
statusCode: null,
statusMessage: null,
client:
{ _connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 2042255,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Circular] },
_consuming: false,
_dumped: false,
next: [Function: next],
baseUrl: '',
originalUrl: '/',
_parsedUrl:
{ protocol: null,
slashes: null,
auth: null,
host: null,
port: null,
hostname: null,
hash: null,
search: null,
query: null,
pathname: '/',
path: '/',
href: '/',
_raw: '/' },
params: {},
query: {},
res: [Circular],
route: { path: '/', stack: [Object], methods: [Object] } },
locals: {} }
undefined
After END
'res' object { domain: null,
_events: { prefinish: [Function: resOnFinish] },
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
writable: true,
_last: false,
chunkedEncoding: true,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_removedHeader: {},
_hasBody: true,
_trailer: '',
finished: true,
_hangupClose: false,
socket: null,
connection: null,
_headers: { 'x-powered-by': 'Express' },
_headerNames: { 'x-powered-by': 'X-Powered-By' },
req:
{ _readableState:
{ objectMode: false,
highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null,
resumeScheduled: true },
readable: true,
domain: null,
_events: {},
_maxListeners: undefined,
socket:
{ _connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 136,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 2042291,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: null },
connection:
{ _connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 136,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 2042291,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: null },
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: false,
headers:
{ host: '
127.0.0.1:4000',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'accept-language': 'ca,en-us;q=0.7,en;q=0.3',
'accept-encoding': 'gzip, deflate',
connection: 'keep-alive',
'cache-control': 'max-age=0' },
rawHeaders:
[ 'Host',
'
127.0.0.1:4000',
'User-Agent',
'Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0',
'Accept',
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language',
'ca,en-us;q=0.7,en;q=0.3',
'Accept-Encoding',
'gzip, deflate',
'Connection',
'keep-alive',
'Cache-Control',
'max-age=0' ],
trailers: {},
rawTrailers: [],
_pendings: [],
_pendingIndex: 0,
upgrade: false,
url: '/',
method: 'GET',
statusCode: null,
statusMessage: null,
client:
{ _connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 319,
_bytesDispatched: 136,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 2042291,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: null },
_consuming: false,
_dumped: true,
next: [Function: next],
baseUrl: '',
originalUrl: '/',
_parsedUrl:
{ protocol: null,
slashes: null,
auth: null,
host: null,
port: null,
hostname: null,
hash: null,
search: null,
query: null,
pathname: '/',
path: '/',
href: '/',
_raw: '/' },
params: {},
query: {},
res: [Circular],
route: { path: '/', stack: [Object], methods: [Object] } },
locals: {},
statusMessage: 'OK',
statusCode: 200,
_header: 'HTTP/1.1 200 OK\r\nX-Powered-By: Express\r\nDate: Tue, 27 Jan 2015 15:48:37 GMT\r\nConnection: keep-alive\r\nTransfer-Encoding: chunked\r\n\r\n',
_headerSent: true }
It appears a "res._headers" property, a "res._header" property and a "req.headers" object (inside res!?) but there aren't any "res.headers" object. Sorry but my knowledge doesnt' go more far away...