node.js doc says
This method signals to the server that all of the response headers and body have been sent; that server should consider this message complete. The method, response.end(), MUST be called on each response.
but in the many examples given using using createReadStream
, eg,
fs.createReadStream(filename,{...}).pipe(response)
I never see response.end()
called.
it resonse.end()
needed with createReadStream()
? and, if so, where does it appear in the program flow - you don't want it called until the pipe is finished, right?
You do response.end()
after reading is finished (end
event) or you encounter an error (error
event).
Check this example: http://elegantcode.com/2011/04/06/taking-baby-steps-with-node-js-pumping-data-between-streams/