Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-734

When create UrlEncodedFormEntity, "~" is not encoded as %7E

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Invalid
    • 5.2.1
    • None
    • HttpCore
    • None

    Description

      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.

      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); 
      

       

      While the encoding was working correctly with httpclient (4.5.13).

      Attachments

        Activity

          People

            Unassigned Unassigned
            phoebemaomao phoebe chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: