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

Behaviour of BasicHttpRequest wrt. path is inconsistent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.1, 5.2, 5.3-alpha1
    • 5.3-alpha2
    • HttpCore
    • None
    • Patch

    Description

      The Setter for path in BasicHttpRequest checks whether the parameter path starts with two slashes and - if so - throws an IllegalArgumentException (through the call to Args.check(...). Similarly, method setUri(...) checks the raw path from tur URI.

      This leads to inconsistent behaviour. A constructor call like:

      new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "//search/asdf?q=foobar");
      

      works fine, while a constructor call like:

      new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "doesNotMatter")
                  .setPath("//search/asdf?q=foobar");
      

      or

      new BasicHttpRequest("GET", URI.create("https://www.google.com//search/asdf?q=foobar"));
      

      throws an IllegalArgumentException.

      The Class BasicHttpRequest was extended in commit 1614d5d and is present since.

      I think what should happen is that the path should only be checked for // if the authority is not set since RFC 3986 in section 3 specifies:

         The scheme and path components are required, though the path may be
         empty (no characters).  When authority is present, the path must
         either be empty or begin with a slash ("/") character.  When
         authority is not present, the path cannot begin with two slash
         characters ("//").
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            turing85 Marco Bungart
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m