Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Given: A request with content-type „application/x-www-form-urlencoded; charset=ISO-8859-1“. When an http status code of 307 is received, then the charset of the content-type header is altered to UTF-8 and the body is re-encoded in the following transmission.
The log snippet shows that the body changes from
"echotext=TEST%F6TEST"
to
"echotext=TEST%C3%B6TEST".
HttpClient Version: 4.5.13
code snippet:
CloseableHttpClient httpclient = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build(); HttpPost httpPost = new HttpPost("http://localhost:8080/Testservlet/redirect/echoTest"); // Testservlet responds with http status 307 List<BasicNameValuePair> nvps = new ArrayList<>(); nvps.add(new BasicNameValuePair("echotext", "TESTöTEST")); httpPost.setEntity(new UrlEncodedFormEntity(nvps, Charset.forName("ISO-8859-1"))); CloseableHttpResponse response = httpclient.execute(httpPost);
log snippet:
2021/03/24 12:40:30:767 MEZ [DEBUG] MainClientExec - Opening connection {}->[http://localhost:8080|http://localhost:8080/] 2021/03/24 12:40:30:767 MEZ [DEBUG] DefaultHttpClientConnectionOperator - Connecting to localhost/127.0.0.1:8080 2021/03/24 12:40:30:782 MEZ [DEBUG] DefaultHttpClientConnectionOperator - Connection established 127.0.0.1:51227<->127.0.0.1:8080 2021/03/24 12:40:30:782 MEZ [DEBUG] MainClientExec - Executing request POST /Testservlet/redirect/echoTest HTTP/1.1 2021/03/24 12:40:30:782 MEZ [DEBUG] MainClientExec - Target auth state: UNCHALLENGED 2021/03/24 12:40:30:782 MEZ [DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED 2021/03/24 12:40:30:782 MEZ [DEBUG] headers - http-outgoing-0 >> POST /Testservlet/redirect/echoTest HTTP/1.1 2021/03/24 12:40:30:782 MEZ [DEBUG] headers - http-outgoing-0 >> Content-Length: 20 2021/03/24 12:40:30:782 MEZ [DEBUG] headers - http-outgoing-0 >> Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1 2021/03/24 12:40:30:782 MEZ [DEBUG] headers - http-outgoing-0 >> Host: localhost:8080 2021/03/24 12:40:30:782 MEZ [DEBUG] headers - http-outgoing-0 >> Connection: Keep-Alive 2021/03/24 12:40:30:782 MEZ [DEBUG] headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0) 2021/03/24 12:40:30:782 MEZ [DEBUG] headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "POST /Testservlet/redirect/echoTest HTTP/1.1[\r][\n]" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "Content-Length: 20[\r][\n]" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "{color:#ffab00}Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1[\r][\n]{color}" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "Host: localhost:8080[\r][\n]" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0)[\r][\n]" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "[\r][\n]" 2021/03/24 12:40:30:782 MEZ [DEBUG] wire - http-outgoing-0 >> "{color:#ffab00}echotext=TEST%F6TEST{color}" 2021/03/24 12:40:30:795 MEZ [DEBUG] wire - http-outgoing-0 << "HTTP/1.1 307 [\r][\n]" 2021/03/24 12:40:30:795 MEZ [DEBUG] wire - http-outgoing-0 << "Location: [http://localhost:8080/Testservlet/echoTest[\r][\n|http://localhost:8080/Testservlet/echoTest%5b/r%5d%5b/n]]" 2021/03/24 12:40:30:795 MEZ [DEBUG] wire - http-outgoing-0 << "Content-Length: 0[\r][\n]" 2021/03/24 12:40:30:795 MEZ [DEBUG] wire - http-outgoing-0 << "Date: Wed, 24 Mar 2021 11:40:30 GMT[\r][\n]" 2021/03/24 12:40:30:795 MEZ [DEBUG] wire - http-outgoing-0 << "Keep-Alive: timeout=20[\r][\n]" 2021/03/24 12:40:30:795 MEZ [DEBUG] wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]" 2021/03/24 12:40:30:795 MEZ [DEBUG] wire - http-outgoing-0 << "[\r][\n]" 2021/03/24 12:40:30:795 MEZ [DEBUG] headers - http-outgoing-0 << {color:#ffab00}HTTP/1.1 307{color} 2021/03/24 12:40:30:795 MEZ [DEBUG] headers - http-outgoing-0 << Location: [http://localhost:8080/Testservlet/echoTest] 2021/03/24 12:40:30:795 MEZ [DEBUG] headers - http-outgoing-0 << Content-Length: 0 2021/03/24 12:40:30:795 MEZ [DEBUG] headers - http-outgoing-0 << Date: Wed, 24 Mar 2021 11:40:30 GMT 2021/03/24 12:40:30:795 MEZ [DEBUG] headers - http-outgoing-0 << Keep-Alive: timeout=20 2021/03/24 12:40:30:795 MEZ [DEBUG] headers - http-outgoing-0 << Connection: keep-alive 2021/03/24 12:40:30:795 MEZ [DEBUG] MainClientExec - Connection can be kept alive for 20000 MILLISECONDS 2021/03/24 12:40:30:795 MEZ [DEBUG] PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->[http://localhost:8080|http://localhost:8080/]] can be kept alive for 20.0 seconds 2021/03/24 12:40:30:795 MEZ [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0 2021/03/24 12:40:30:795 MEZ [DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->[http://localhost:8080][total|http://localhost:8080][total/] available: 1; route allocated: 1 of 2; total allocated: 1 of 20] 2021/03/24 12:40:30:795 MEZ [DEBUG] LaxRedirectStrategy - Redirect requested to location 'http://localhost:8080/Testservlet/echoTest' 2021/03/24 12:40:30:811 MEZ [DEBUG] RedirectExec - Redirecting to 'http://localhost:8080/Testservlet/echoTest' via {}->[http://localhost:8080|http://localhost:8080/] 2021/03/24 12:40:30:811 MEZ [DEBUG] RequestAddCookies - CookieSpec selected: default 2021/03/24 12:40:30:811 MEZ [DEBUG] RequestAuthCache - Auth cache not set in the context 2021/03/24 12:40:30:811 MEZ [DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {}->[http://localhost:8080][total|http://localhost:8080][total/] available: 1; route allocated: 1 of 2; total allocated: 1 of 20] 2021/03/24 12:40:30:811 MEZ [DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->[http://localhost:8080][total|http://localhost:8080][total/] available: 0; route allocated: 1 of 2; total allocated: 1 of 20] 2021/03/24 12:40:30:811 MEZ [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0 2021/03/24 12:40:30:811 MEZ [DEBUG] MainClientExec - Executing request POST /Testservlet/echoTest HTTP/1.1 2021/03/24 12:40:30:811 MEZ [DEBUG] MainClientExec - Target auth state: UNCHALLENGED 2021/03/24 12:40:30:811 MEZ [DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED 2021/03/24 12:40:30:811 MEZ [DEBUG] headers - http-outgoing-0 >> POST /Testservlet/echoTest HTTP/1.1 2021/03/24 12:40:30:811 MEZ [DEBUG] headers - http-outgoing-0 >> Content-Length: 23 2021/03/24 12:40:30:811 MEZ [DEBUG] headers - http-outgoing-0 >> Content-Type: application/x-www-form-urlencoded; charset=UTF-8 2021/03/24 12:40:30:811 MEZ [DEBUG] headers - http-outgoing-0 >> Host: localhost:8080 2021/03/24 12:40:30:811 MEZ [DEBUG] headers - http-outgoing-0 >> Connection: Keep-Alive 2021/03/24 12:40:30:811 MEZ [DEBUG] headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0) 2021/03/24 12:40:30:811 MEZ [DEBUG] headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "POST /Testservlet/echoTest HTTP/1.1[\r][\n]" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "Content-Length: 23[\r][\n]" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "{color:#ffab00}Content-Type: application/x-www-form-urlencoded; charset=UTF-8[\r][\n]{color}" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "Host: localhost:8080[\r][\n]" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0)[\r][\n]" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> "[\r][\n]" 2021/03/24 12:40:30:811 MEZ [DEBUG] wire - http-outgoing-0 >> {color:#ffab00}"echotext=TEST%C3%B6TEST{color}" 2021/03/24 12:40:30:826 MEZ [DEBUG] wire - http-outgoing-0 << "HTTP/1.1 200 [\r][\n]" 2021/03/24 12:40:30:826 MEZ [DEBUG] wire - http-outgoing-0 << "Content-Type: application/json;charset=UTF-8[\r][\n]" 2021/03/24 12:40:30:826 MEZ [DEBUG] wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]" 2021/03/24 12:40:30:826 MEZ [DEBUG] wire - http-outgoing-0 << "Date: Wed, 24 Mar 2021 11:40:30 GMT[\r][\n]" 2021/03/24 12:40:30:826 MEZ [DEBUG] wire - http-outgoing-0 << "Keep-Alive: timeout=20[\r][\n]"
Attachments
Issue Links
- relates to
-
HTTPCLIENT-2159 Invalid handling of charset content type parameter
- Resolved