HttpComponents HttpClient
  1. HttpComponents HttpClient
  2. HTTPCLIENT-730

Use of Multi-Args URI Causes URI-Rewriting to improperly unescape characters

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0 Alpha 2
    • Fix Version/s: 4.0 Alpha 3
    • Component/s: HttpClient
    • Labels:
      None

      Description

      See: http://www.nabble.com/unable-to-encode-reserved-characters-using-java.net.URI-multi-arg-constructors-td14954679.html for information from the httpclient-dev thread. The basic idea is that URI's multi-arg constructors break things.

        Activity

        Hide
        Oleg Kalnichevski added a comment -

        Applied a fixed similar to that suggested by Sam. All tests pass for me now. Please review.

        Oleg

        Show
        Oleg Kalnichevski added a comment - Applied a fixed similar to that suggested by Sam. All tests pass for me now. Please review. Oleg
        Hide
        Tim Julien added a comment -

        could probably steal java.net.URI.defineString() for a general purpose method to build a complete String URI to be used in conjunction with java.net.URI(String s)

        Show
        Tim Julien added a comment - could probably steal java.net.URI.defineString() for a general purpose method to build a complete String URI to be used in conjunction with java.net.URI(String s)
        Hide
        Sam Berlin added a comment -

        Per the email thread, placing


        String path = uri.getRawPath();
        String query = uri.getRawQuery();
        String fragment = uri.getRawFragment();
        String newUri =
        (path == null ? "" : path)
        + (query == null ? "" : ("?" + query))
        + (fragment == null ? "" : ("#" + fragment));
        request.setURI(new URI(newUri));

        in DefaultClientRequestDirector.rewriteRequestURI else if branch will fix it, but I don't know how stable that is.

        Show
        Sam Berlin added a comment - Per the email thread, placing String path = uri.getRawPath(); String query = uri.getRawQuery(); String fragment = uri.getRawFragment(); String newUri = (path == null ? "" : path) + (query == null ? "" : ("?" + query)) + (fragment == null ? "" : ("#" + fragment)); request.setURI(new URI(newUri)); – in DefaultClientRequestDirector.rewriteRequestURI else if branch will fix it, but I don't know how stable that is.
        Hide
        Sam Berlin added a comment -

        A testcase specifically DefaultClientRequestDirector.rewriteRequestURI's else branch. I'm not positive how to setup the environment to test the if branch. There's still three of untested uses of URI's multi-arg constructor, but this is a good easy-to-test first step.

        Show
        Sam Berlin added a comment - A testcase specifically DefaultClientRequestDirector.rewriteRequestURI's else branch. I'm not positive how to setup the environment to test the if branch. There's still three of untested uses of URI's multi-arg constructor, but this is a good easy-to-test first step.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sam Berlin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development