Issue Details (XML | Word | Printable)

Key: JRUBY_RACK-15
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: michaelpitman
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
jruby-rack

RackRewindableInput will sometimes not process the entire POST payload

Created: 30/Jun/09 03:21 AM   Updated: 20/Aug/09 10:16 PM   Resolved: 20/Aug/09 10:16 PM
Component/s: None
Affects Version/s: 0.9.4
Fix Version/s: 0.9.5

Time Tracking:
Not Specified

Environment:

Jetty 6.1


Tags:


 Description  « Hide

We were getting truncated POST packets and garbled params in some of our larger post requests. It looks like (though I don't know why) the population of the in-memory ByteBuffer from the Jetty input stream was not copying all the data in one call.

The following patch forces multiple passes of the input stream until it is exhausted. This is not extensively tested, particularly in a multi-threaded environment, but it fixes the problem for us in a traditional (Rails 2.1.2) environment.

— a/src/main/java/org/jruby/rack/input/RackRewindableInput.java
+++ b/src/main/java/org/jruby/rack/input/RackRewindableInput.java
@@ -71,7 +71,7 @@ public class RackRewindableInput extends RackBaseInput {

private MemoryBufferRackInput(ReadableByteChannel input) throws
IOException { memoryBuffer = ByteBuffer.allocate(getBufferSize()); - input.read(memoryBuffer); + while (input.read(memoryBuffer) > 0 && memoryBuffer.hasRemaining()); full = !memoryBuffer.hasRemaining(); memoryBuffer.flip(); }



Nick Sieger added a comment - 20/Aug/09 10:16 PM

In f5ee0d9.