On Mon, 2006-04-03 at 15:48 +0530, Ramit bhardwaj wrote: > Where does it say to use Stream after a certain limit?? I am pasting the API > here: > > > getResponseBody > byte[] getResponseBody() > throws IOException > Returns the response body of the HTTP method, if any, as an array of bytes. > If the method has not yet been executed or the response has no body, null is > returned. Note that this method does not propagate I/O exceptions. If an > error occurs while reading the body, null will be returned. > > Returns: > The response body, or null if the body is not available. > Throws: > IOException - if an I/O (transport) problem occurs > > > > I am using it for a highly avaliable mission critical enterprise application > and it seems to work fine. Hence I am curious to know... > >
Ramit, This is actually correct. See http://jakarta.apache.org/commons/httpclient/xref/org/apache/commons/httpclient/HttpMethodBase.html#652 The use of HttpMethod#getResponseBody and HttpMethod#getResponseBodyAsString is *strongly* discouraged. Both methods attempt to buffer the entire response content in memory. A badly written or malicious server-side script can bring your app down with an OutOfMemoryError, if the server generates more data that your JRE can allocate. That is why it is generally recommended to use HttpMethod#getResponseBodyAsStream method if your application must be prepared to deal with any arbitrary responses including those that generate infinite content stream, and introduce additional application specific safe-guards in your code (such as method abort after reaching a certain content length threshold) Oleg > > -----Original Message----- > From: Sheetal D [mailto:[EMAIL PROTECTED] > Sent: Monday, April 03, 2006 3:31 PM > To: HttpClient User Discussion > Subject: RE: Request > > Thanks, But it tells to use Stream after a certain limit. > > Thanks, > Sheetal > > > Ramit bhardwaj <[EMAIL PROTECTED]> wrote: > > > What about getResponseBody() method. It returns a byte array. > > > -----Original Message----- > From: Sheetal D [mailto:[EMAIL PROTECTED] > Sent: Monday, April 03, 2006 2:48 PM > To: [email protected] > Subject: Request > > Hi all, > I have a doubt on the way Http Client response bieng read, HttpMethod > returns Stream or String as response content. I see no method returns byte > as output. Is there any reason for that > > Thanks, > Sheetal > > > > --------------------------------- > Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates > starting at 1ยข/min. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------- > New Yahoo! Messenger with Voice. Call regular phones from your PC and save > big. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
