Driving a SAX parser with received HTTP chunks

Mathew Johnston mjohnston at capsaicin.ca
Mon Jan 10 19:27:23 EST 2011


Hi all,

I have an application built on Netty that receives large XML messages over
HTTP POST. These are chunked. Right now, I'm simply using the chunk
aggregator, getting a String from the ContentBuffer (using HTTP Content-Type
for encoding info) and wrapping that in a StringReader, wrapping that in an
InputSource and passing it to the SAXParser. Obviously, this isn't ideal.

I'd like to drive the SAX parser with the chunks as they're received. I
theorize that I would need some sort of OutputStream that generates SAX
events (calls methods of my handler) as I write(). I can't find such a
thing. Does it exist? Is it a flawed idea? Is there any way to have Netty
expose the chunk stream as an InputStream?

The next best thing I've found is the PipedInputStream, but that would
require additional threadding that I'd like to avoid.

Any thoughts? Obviously SAX is meant to deal with this kind of problem -
it's simply an issue of how Netty/the pipline presents the received chunks
to the parser. This has to be a common problem for someone to want to
solve.

Cheers,
Mathew Johnston
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20110110/3f211cb4/attachment.html 


More information about the netty-users mailing list