You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by bu...@apache.org on 2004/07/02 15:53:21 UTC
DO NOT REPLY [Bug 29883] -
StringRequestEntity.getContentLength wrong for multibyte chars
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29883>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=29883
StringRequestEntity.getContentLength wrong for multibyte chars
------- Additional Comments From susp51@verit.de 2004-07-02 13:53 -------
Workaround:
// FIXME: This is a workaround for httpClient 3.0alpha1 bug
// concerning content-length and multi-byte chars
if (method instanceof EntityEnclosingMethod) {
EntityEnclosingMethod eeMethod = (EntityEnclosingMethod) method;
final String charset = eeMethod.getRequestCharSet();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eeMethod.getRequestEntity().writeRequest(baos);
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
// better use InputStreamRequestEntity, but you get the picture
eeMethod.setRequestBody(bais);
}
httpClient.executeMethod(method);
P.S.: eclipse debugger gave me this stacktrace to see the bug at work:
Thread [HttpClient-Client-Server-0] (Suspended)
StringRequestEntity.getContentLength() line: 140
PostMethod(EntityEnclosingMethod).getRequestContentLength() line: 322
PostMethod(EntityEnclosingMethod).addContentLengthRequestHeader(HttpState,
HttpConnection) line: 392
PostMethod(EntityEnclosingMethod).addRequestHeaders(HttpState, HttpConnection)
line: 360
PostMethod(HttpMethodBase).writeRequestHeaders(HttpState, HttpConnection) line:
1977
PostMethod(HttpMethodBase).writeRequest(HttpState, HttpConnection) line: 1865
PostMethod(HttpMethodBase).execute(HttpState, HttpConnection) line: 975
HttpMethodDirector.executeWithRetry(HttpMethod) line: 368
HttpMethodDirector.executeMethod(HttpMethod) line: 164
HttpClient.executeMethod(HostConfiguration, HttpMethod, HttpState) line: 437
HttpClient.executeMethod(HttpMethod) line: 324
HttpClientThread.run() line: 96
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org