netty/netty — pull request #1199 by mauricio (2013-03-23 15:56:30+00:00)
Title: Adding event hooks to HttpPostRequestDecoder and creating EventedHttpPostRequestDecoder to simplify the way we work with streaming HTTP post requests

When using `HttpPostRequestDecoder` directly you have to call `next()/hasNext()` after calling `offer`. This is all good and fine if you just want to grab the data, but in my case I needed to proxy the contents of the files being uploaded and I created a simple `FileUpload` adapter that would proxy this data to the place I want it to go (in this case it was S3) instead of writing it to disk.

The issue is that I needed all parameters before the file was created but when I had a large buffer being offered to the decoder, it would both parse the fields and initialise the upload before I got to call `next` so my file started streaming before I could really start the streaming process.

To solve this issue I used the solution proposed in this pull request, I created hooks at the `HttpPostRequestDecoder` and in it's subclass, `EventedHttpPostRequestDecoder' I implemented them using a listener that resembles a SAX parser. I did not add this functionality directly inside `HttpPostRequestDecoder` because this seems like a very specific need and not everyone would need that (and it could also incur in some performance being lost due to the listener dispatch and all).

This was really useful to me and I believe it might also be useful for other people so I have created this PR. If it gets accepted I can also send it upstream to the master branch, I didn't do it here because we are still using Netty 3.x.

Thanks!