stormbrew/rack-jetty — pull request #6 by regularfry (2012-12-12 14:16:25+00:00)
Title: JavaInput doesn't duck-type to IO

Hi,

There's a problem with the `JavaInput` class which means that it unfortunately breaks if the `InputStream` needs to be read in more than one `read` call. `IO#read(len, buffer)` is expected to replace the buffer contents with what it gets from the stream, but the current version of `JavaInput` doesn't do that - it appends instead. This means that, for instance, data being read from an HTTPS POST can be corrupted. It's a right sod to track down when it happens, too.

I've put together a couple of specs to show the correct behaviour (as relied upon by `Rack::RewindableInput`) so you can see how the breakage shows up, and the fix is very simple.