Hi,

I'm implementing custom HTTP reverse proxy using Undertow.
My server is listening to requests and when a new request arrives, It wraps the request in a proprietary protocol and redirect to another component in my system.
That component takes the request data, unpack it, send it to the actual web server, get's the response and send the response back to my Undertow server in the same proprietary protocol.
The server unpacks the response and writes it back to the user's browser.

All works very well for "small" requests/response but for request/response that has body data that exceed some predefined amount I would like to split the request/response to chunks ( my own chunking mechanism, not related to HTTP chunking) to better handle such scenarios and not hold the entire data in the server's memory.

In order to do that I need access to the request/response body bytes,
I came by this thread: http://lists.jboss.org/pipermail/undertow-dev/2015-January/001080.html and tried to implement both proposed solutions

When I used the async interface:

HttpServerExchange.getResponseSender().send(bodyByteBuffer, myIoCallback)

Sometimes my callback just not called ( nor the onComplete or the onException callbacks) for unknown reasons.

So I tried the blocking interface instead ( from dispatched handler ):

HttpServerExchange.startBlocking()

HttpServerExchange.getResponseSender().send(bodyByteBuffer)

That works but I read somewhere in this mailing list that the async interface is more efficient.

The same behavior occurred when trying to receive the request body using:
HttpServerExchange.getRequestReceiver()
and also solved using the blocking interface.

Am I missing something? what are the best practices for reading/writing partial request/response body?

Best,
Eldad.