Good morning,

Currently HttpResponseEncoder only seems to support HttpResponses that contain all the data that is going to be in the response. This clearly does not work for streaming data.

I needed immediate support for streaming data, so I added a ChunkedHttpResponseEncoder that supports sending arbitrary data as part of the response after the actual HttpResponse-object is sent. I think my interface is ugly, so hopefully someone can come up with a better idea. It seems clear to me that streaming data should be supported.

Description of my encoder:

ChunkedHttpResponseEncoder first expects an HttpResponse, and if the HttpResponse has Transfer-encoding: chunked set, switches to expecting HttpChunks instead. HttpChunks are simply containers for IoBuffers, and are simply written to the Iosession, prefixed with the appropriate chunk header. The response is terminated with a special END_TOKEN objec. When the encoder receives an END_TOKEN, it switches back to expecting HttpResponses.

If the encoder receives an inappropriate object for its current state (END_TOKEN or HttpChunk when expecting HttpResponse, or HttpResponse when expecting HttpChunk or END_TOKEN, it throws an exception).

Tuure Laurinolli

Reply via email to