Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-646

HttpClient.executeMethod with absolute URI removes the Protocol from the hostConfiguration

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 3.1 RC1
    • None
    • HttpClient (classic)
    • None

    Description

      Testprogram (snippet):

      public void test() throws IOException
      {
      String url = "https://www.somehost.com/somepath";
      URL u = new URL(url);
      Protocol protocol = new Protocol("https", new AcceptAllSSLProtocolSocketFactory(), port);
      HttpClient httpClient = new HttpClient();
      httpClient.getHostConfiguration().setHost(u.getHost(), port, protocol);
      GetMethod m = new GetMethod(url);
      httpClient.httpClient.executeMethod(m);
      System.out.println("status=" + m.getStatusCode());
      }

      Suggested fix in method public int executeMethod(HostConfiguration hostconfig, final HttpMethod method, final HttpState state)

      ....
      // make a deep copy of the host defaults
      hostconfig = (HostConfiguration) hostconfig.clone();
      if (uri.isAbsoluteURI()) {
      //hostconfig.setHost(uri); <-- this line replaces the Protocol with the default one
      hostconfig.setHost(uri.getHost(), uri.getPort(), hostconfig.getProtocol());
      }
      ....

      Attachments

        Activity

          People

            Unassigned Unassigned
            toemmi Thomas Mathis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: