sonatype/async-http-client — pull request #67 by bd808 (2012-03-22 23:51:32+00:00)
Title: Fix large payload bugs in ByteArrayBodyGenerator.

Fixes three bugs exposed when a ByteArrayBodyGenerator is used to
pass a POST body to the AsyncHttpProvider that is larger than the
AsyncHttpProvider's BodyChunkedInput buffer size. Found when using the Netty
provider to pass a 50k+ POST body.

A read from a ByteBody having more content than the buffer could hold would
return a full read buffer but incorrectly compute the internal pointer for the
remaining content by subtracting the read length from the total content size
rather than adding it to the current read position.

A subsequent read from the same ByteBody would result in
a java.lang.IndexOutOfBoundsException due to improperly passing the total
length of the current body as the length argument to ByteBuffer.put() rather
than the number of bytes to read from the offset.

ByteArrayBodyGenerator.ByteBody also incorrectly implemented the Body
interface by returning the total body length for each non-EOF read rather
than the actual number of bytes read.

All three of these bugs would not be seen unless the body size was greater
than the capacity of a single buffer.