This question is related to the excellent answer by Youssef. I love OnSendingHeaders
callback. I can now add the response headers without worrying about switching s
What do you want to do with the response body?
This callback is invoked on first write, so it's too late to replace the stream. You also can't read from the response stream as there is nothing stored in it normally. This is normally a write-only stream that goes out to the network.
Replacing the response stream earlier is the correct approach here.