You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Christine Karman <my...@christine.nl> on 2011/05/11 19:06:21 UTC

4k buffer limit?

Hi,
I'm reading an inputstream, but somehow the input gets chopped off at 
around 4k characters. I'm reading the characters one by one from the 
input stream. I've never seen this before, but then, maybe I've never 
read input more than 4k at a time. Does it ring a bell  with somone? 
What can I do wrong to chop the input at around 4030 characters?

Thanks in advance....

dagdag
Christine

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4k buffer limit?

Posted by Christine <my...@christine.nl>.
On 05/11/2011 10:42 PM, Edward Sumerfield wrote:
> You don't need to read bytes one at a time. Instead wrap your input stream
> in a buffered input stream so you can read many at once. This is far more
> efficient.
I know, I just tried to see if that makes a difference. I use readline 
on a bufferedreader. But Oleg just remarked that that may not be efficient.
I found the problem, it was not in HttpClient. Thanks for the replies.

dagdag
Christine
> If you post your code we may be able to give you a more specific answer.
>
> Sent from Incredible Android.
> On May 11, 2011 1:06 PM, "Christine Karman"<my...@christine.nl>  wrote:
>> Hi,
>> I'm reading an inputstream, but somehow the input gets chopped off at
>> around 4k characters. I'm reading the characters one by one from the
>> input stream. I've never seen this before, but then, maybe I've never
>> read input more than 4k at a time. Does it ring a bell with somone?
>> What can I do wrong to chop the input at around 4030 characters?
>>
>> Thanks in advance....
>>
>> dagdag
>> Christine
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4k buffer limit?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2011-05-11 at 16:42 -0400, Edward Sumerfield wrote:
> Bytes read from an input stream go into buffer and you control how long that
> is. However, you don't need to increase the size but should always read the
> stream dry before finishing.
> 
> The jdk methods usually return the # bytes read or -1 for end of stream. You
> just keep calling read until you get eos.
> 
> You don't need to read bytes one at a time. Instead wrap your input stream
> in a buffered input stream so you can read many at once. This is far more
> efficient.
> 

Just one small remark. HttpClient maintains an internal session buffer
(8kb per default) for all read operations, which makes additional
buffering unnecessary. Ironically, wrapping of content stream with an
BufferedInputStream likely makes data streaming less efficient.

Oleg 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4k buffer limit?

Posted by Edward Sumerfield <es...@gmail.com>.
Bytes read from an input stream go into buffer and you control how long that
is. However, you don't need to increase the size but should always read the
stream dry before finishing.

The jdk methods usually return the # bytes read or -1 for end of stream. You
just keep calling read until you get eos.

You don't need to read bytes one at a time. Instead wrap your input stream
in a buffered input stream so you can read many at once. This is far more
efficient.

If you post your code we may be able to give you a more specific answer.

Sent from Incredible Android.
On May 11, 2011 1:06 PM, "Christine Karman" <my...@christine.nl> wrote:
> Hi,
> I'm reading an inputstream, but somehow the input gets chopped off at
> around 4k characters. I'm reading the characters one by one from the
> input stream. I've never seen this before, but then, maybe I've never
> read input more than 4k at a time. Does it ring a bell with somone?
> What can I do wrong to chop the input at around 4030 characters?
>
> Thanks in advance....
>
> dagdag
> Christine
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>