getResponseBodyAsStream vs. getResponseBodyAsString

View: New views
2 Messages — Rating Filter:   Alert me  

getResponseBodyAsStream vs. getResponseBodyAsString

by Randy Paries-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
For additional commands, e-mail: httpclient-users-help@...


Re: getResponseBodyAsStream vs. getResponseBodyAsString

by Douglas Ferguson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
> For additional commands, e-mail: httpclient-users-help@...
>


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