Am Freitag, 10. Oktober 2003 17:01 schrieb Eric Johnson: > I would think that if your application has any reason to believe that > the response will be unbounded, then you should use > getResponseBodyAsStream. > > I suppose would could add functions that took a limit parameter for the > functions getResponseBody() and getResponseBodyAsString(). Something like: > > byte[] getResponseBody(int maxBytes); > > and deprecate the old one. In the absence of such support in > HttpClient, presumably you can write such a function for yourself? > > I agree with other posts that this is not an issue to solve at the > stream level. > > -Eric.
Eric, adding a maxBytes parameter to getResponseBody seems to be a resonable idea to limit the actual number of bytes returned in the response body. Nevertheless, you would still have to fix some other flaws lying around at lower levels that attempt to read until EOF or newline, such as ChunkedInputStream.close() and exhaustInputStream() - or HttpParser.readRawline(). I can easily provide test cases which will cause HttpClient to eat up all available memory throwing an OutOfMemoryError because of reading and reading from a never ending HTTP Response. I would regard this behaviour as a bug. The patch is intended as an "emergency brake" if methods at higher levels try to read until EOF. It is up to the user whether to set this hard limit or not. Christian --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]