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 Randy Paries <rt...@gmail.com> on 2009/10/08 19:25:31 UTC
getResponseBodyAsStream vs. getResponseBodyAsString
I was wondering if someone could give me insight on when to use
getResponseBodyAsStream vs. getResponseBodyAsString
The getResponseBodyAsString seems to be very straight forward but
would like to understand the best scenarios for each
thanks
Randy
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: getResponseBodyAsStream vs. getResponseBodyAsString
Posted by Douglas Ferguson <do...@douglasferguson.us>.
It really depends on your usecase.
getResponseBodyAsString will buffer the entire response into a String,
which could cause unnecessary memory usage. If you are going to turn
around and stream the response somewhere, i.e. disc or servlet response.
Also, keep in mind that getResponseBodyAsString will have to deal with
character encoding. My experience with 3.1 is that it doesn't work too
well. I had to override it with the mozilla library for charset
detection.
Hope this helps.
Douglas
On Oct 8, 2009, at 12:25 PM, Randy Paries wrote:
> I was wondering if someone could give me insight on when to use
> getResponseBodyAsStream vs. getResponseBodyAsString
>
> The getResponseBodyAsString seems to be very straight forward but
> would like to understand the best scenarios for each
>
> thanks
> Randy
>
> ---------------------------------------------------------------------
> 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