[
https://issues.apache.org/jira/browse/HTTPCORE-734?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17690687#comment-17690687
]
phoebe chen commented on HTTPCORE-734:
--------------------------------------
Thanks [~michael-o] for your comment.
With a further look, I figured out the bad request is not actually caused by
the encoding of "~". So this is not a real bug, though still some behavior
difference compared to http client version 4.
> When create UrlEncodedFormEntity, "~" is not encoded as %7E
> -----------------------------------------------------------
>
> Key: HTTPCORE-734
> URL: https://issues.apache.org/jira/browse/HTTPCORE-734
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Components: HttpCore
> Affects Versions: 5.2.1
> Reporter: phoebe chen
> Priority: Major
>
> We are doing upgrade from httpclient (4.5.13) to httpclient5 (5.2.1).
> And after the upgrade, we found when use following sample code to create a
> post request, the request execution will fail with 400 Bad Request error,
> because the character "~" in parameter string is not encoded into %7E. If we
> set the charset for UrlEncodedFormEntity to UTF-8, still hit same issue.
> {code:java}
> HttpPost request = new HttpPost(strUrl);
> List<NameValuePair> parameters = new ArrayList<NameValuePair>();
> parameters.add(new BasicNameValuePair("name", "a~b"));
> HttpEntity postParams = new UrlEncodedFormEntity(parameters);
> request.setEntity(postParams);
> {code}
>
> While the encoding was working correctly with httpclient (4.5.13).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]