Memory overflow protection for getResponseBody()
------------------------------------------------
Key: HTTPCLIENT-581
URL: http://issues.apache.org/jira/browse/HTTPCLIENT-581
Project: Jakarta HttpClient
Type: Improvement
Components: HttpClient
Versions: 2.0.2, 3.0 Final, 3.0.1
Reporter: Wouter Zelle
Priority: Minor
Currently we are using getResponseBodyAsString() in our production code, which
calls getResponseBody() . This method logs a warning since version 2.0.2
("Going to buffer response body of large or unknown size. Using
getResponseBodyAsStream instead is recommended."). I want to get rid of those
warnings. The suggestion is to use getResponseAsStream for two reasons:
1. Performance
2. Memory overflow risks
The first is a valid reason to change, but should not be mandated by a library
IMO. It's my call as an application developer to balance the risks against the
rewards of refactoring the code. The second reason is more important, but it
can be handled by the getResponseBody method itself. My suggestion is to add a
new Http Method Param: "http.method.response.maximum.size". Setting this
parameter to a value in bytes should then:
1. Result in an exception if the received message is larger than the supplied
size.
2. No longer warn the user to use getResponseBodyAsStream (by setting the max
size, I've also accepted the performance penalty of getResponseBodyAsString()).
Another alternative to get rid of the warning is to create a custom
implementation of getResponseBodyAsString(), which was suggested to someone
else by a HttpClient developer:
http://mail-archives.apache.org/mod_mbox/jakarta-httpclient-user/200411.mbox/[EMAIL
PROTECTED]
I consider this unacceptable because:
1. I don't want to maintain this code.
2. The suggested code in no way resolves the memory overflow issue, so I
consider it a hack to get rid of the warning.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]