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

Cookie matching issue with virtual hosts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.2.2, 4.2.3
    • 4.2.3
    • HttpClient (classic)
    • None

    Description

      Following HTTPCLIENT-1282, there is an issue with cookie matching : only target host is used for cookie origin, but with virtual host, this value is not the real host from the client point of view.

      As a result, cookies get discarded by httpclient even if they match the virtual host and would have been accepted by a browser.

      See the code of the following methods :

      RequestAddCookies#process()

      HttpHost targetHost = (HttpHost) context.getAttribute( ExecutionContext.HTTP_TARGET_HOST);
      ...
      String hostName = targetHost.getHostName();
      ...
      CookieOrigin cookieOrigin = new CookieOrigin( hostName, port, requestURI.getPath(), conn.isSecure());

      And

      ResponseProcessCookies#process()

      CookieOrigin cookieOrigin = (CookieOrigin) context.getAttribute(ClientContext.COOKIE_ORIGIN);
      ...
      processCookies(it, cookieSpec, cookieOrigin, cookieStore);

      Attachments

        1. TestCookieVirtualHost.java
          7 kB
          Nicolas Richeton

        Activity

          People

            Unassigned Unassigned
            nricheton Nicolas Richeton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: