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

Cannot change requestUri of BasicHttpRequest if it has been set once

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.2, 5.2.1
    • 5.2.2, 5.3-alpha1
    • HttpCore
    • None

    Description

      If the requestUri of a BasicHttpRequest isn’t null and needs to be set to a new value using setUri(newUri), e.g. because a parameter needs to be added to an existing URI, path is changed but not requestUri itself. Thus, the repeated query with getUri() returns the initially set value.

      I assume this could be fixed by setting the requestURI to null at the end of setUri(), as it is done in the other setters. This way it would be reassembled correctly next time it is queried, without caching.

      URI uri = URI.create("http://example.org");
      HttpGet req = new HttpGet(uri);
      System.out.println(req.getUri());
      URI newUri = URI.create("http://not-example.org");
      req.setUri(newUri);
      System.out.println(req.getUri() == newUri); // would expect true 

      Attachments

        1. TestBasicHttpRequest.java
          0.8 kB
          Philipp Schusser

        Activity

          People

            Unassigned Unassigned
            pschusser Philipp Schusser
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: