Hi guys.
I have been fighting this for a while and am not winning.
It is highly likely that I have no clue as to what I am doing ... 🙂 🙂
onend_response: function(req, res, data, next) { res.setHeader('onend_response', 'nothing happens'); next(null,data); }
Is this possible - or must all headers be written in the "onresponse" function ?
( I am able to set response headers quite happily there. )
Solved! Go to Solution.
Hey Robin,
Setting the header as you have should work. The only change I'd make is to call "next" with parameters. Please let me know if you made progress.
The log error gave the answer in this case
stack=Error: 'Cant set headers after they are sent.' at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:357:11) at onend_response
Headers are sent once the first portion of the response content is been sent.
In order to set a header in this section, I was forced to code the "ondata_response" section, saving the data chunks and not passing any data until the end, calling next(null, null) in that section.
The chunks needed to be concatenated in the response section as shown in other posts and doc.
Hey Robin,
Setting the header as you have should work. The only change I'd make is to call "next" with parameters. Please let me know if you made progress.
I am reflecting current body in the line "next(null,data);"
How would you change that ?
The log error gave the answer in this case
stack=Error: 'Cant set headers after they are sent.' at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:357:11) at onend_response
Headers are sent once the first portion of the response content is been sent.
In order to set a header in this section, I was forced to code the "ondata_response" section, saving the data chunks and not passing any data until the end, calling next(null, null) in that section.
The chunks needed to be concatenated in the response section as shown in other posts and doc.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |