Hello,
Is it possible to get the full content of a response body before it’s sent? I’m trying to sign the response and add this signature in a header. There was a similar question on this list a couple of weeks ago, but that one was about signing the incoming
request. My current approach is, in HttpHandler.handleRequest():
- Create a javax.crypto.Signature object
- Use HttpServerExchange. addResponseWrapper() to add a StreamSinkConduit that updates the Signature object as write() is called
- Use HttpServerExchange.addResponseCommitListener() to add a callback that calls Signature.sign() when the response is ready to be sent
Good in theory, but I’m finding that the sign happens before the updates – looks like the Conduit is only active as the response is being sent. Is there something else I should wrap to get the bytes as they’re being added to the response? Even better
would be if I could read them directly from the ResponseCommitListener.beforeCommit() callback. I can see the number of bytes that have been written, but not the actual data.
Note: I’m using Undertow 1.2.x, as we’re on WildFly 9.
--
Vikas Nagaraj