I looked into this further. At first I thought it was related to me
not setting the Content-Length header on the replies, this got lost
when I changed the code to stream attachments back. But it turned out
that wasn't related.
The problem is your code to read from the inputstream does not
allocate any space in the buffer. So the read always returns -1.
In the first sample code you set where you read from
AttachmentInputStream, change the 2 lines before you read data to be:
byte[] buffer = new byte[1024];
int i = -1;
Reading the value of getContentLength() from the AttachmentInputStream
will still return -1 (until I merge this patch in the future to set
Content-Length correctly). But you will be able to read the data.
marty