Have a look at the code in io.undertow.server.handlers.RequestBufferingHandler
This basically fully reads the request (assuming it fits in the buffers), then uses
Connectors.ungetRequestBytes(exchange, bufferedData); to restore the data. You could do
----- Original Message -----
From: "Jaeckle Thomas (INST/ECS1)"
Sent: Wednesday, 20 January, 2016 8:48:49 PM
Subject: [undertow-dev] Reverse-Proxy: Consuming InputStream before delegating to proxy
I have following scenario in which I currently face a problem with Undertow:
I use Undertow as a Reverse-Proxy (via SimpleProxyClientProvider).
I want to enable a Signature-based authentication where the client can sign
the HTTP request with its private key and the Reverse-Proxy (implemented
with Undertow) can check with the client’s public key if it was signed
I do not only want to include HTTP headers (Host, Date, ..) and Method/Path,
but also the request body.
For that I need to consume the HttpServerExchange’s InputStream:
if ( isHttpMethodWithBody (method))
final String body = new Scanner(exchange.getInputStream(), "UTF-8"
).useDelimiter( " \\A " ).next();
Unfortunately in this scenario, the Exchange’s “getRequestChannel()” returns
null as “another party already acquired the channel”.
I found “ Connectors. resetRequestChannel (exchange)”;
But just calling this results after the InputStream was consumed results in a
“IOException : UT001000: Connection closed”.
Is there any way to “consume” the request’s payload, but afterwards simply
forward to the proxy target?
Any help is really appreciated, Thanks!
undertow-dev mailing list