encoding problem in httpMethodBase#writeRequestLine(HttpState, HttpConnection)
------------------------------------------------------------------------------
Key: HTTPCLIENT-603
URL: http://issues.apache.org/jira/browse/HTTPCLIENT-603
Project: HttpComponents HttpClient
Issue Type: Bug
Components: HttpClient
Affects Versions: 3.0.1, 3.1 Alpha 1, Nightly Builds
Reporter: Jean Seurin
Trying to encode Chinese character in URL, I had to play with setContentCharset
method.
I had to debug HttpClient since setting this parameter had no effect.
I realized that in
<Code>
protected void writeRequestLine(HttpState state, HttpConnection conn)
throws IOException, HttpException {
LOG.trace(
"enter HttpMethodBase.writeRequestLine(HttpState, HttpConnection)");
String requestLine = getRequestLine(conn);
if (Wire.HEADER_WIRE.enabled()) {
Wire.HEADER_WIRE.output(requestLine);
}
conn.print(requestLine, getParams().getHttpElementCharset());
}
</Code>
conn.print(requestLine, getParams().getHttpElementCharset()); should be
conn.print(requestLine, getParams().getContentCharset());
since it is used to write the content line to the connection and not the header.
With the current code, to be able to successfully send UTF-8 encoding char, I
have to use:
client.getParams().setHttpElementCharset("UTF-8");
which seems to be bad practice according to the doc. Header encoding should
always use its default"US-ASCII"
--
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]