Christoph Lee created HTTPCLIENT-2415:
-----------------------------------------

             Summary: Cookie not send if path attribute is the same as request 
path with query params
                 Key: HTTPCLIENT-2415
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2415
             Project: HttpComponents HttpClient
          Issue Type: Bug
    Affects Versions: 5.6
            Reporter: Christoph Lee


If a cookie has a paht attribute other than '/' the cookie is not added to 
requests that have the same path but with a query parameter (e.g. /path?foo).

*example*
* Cookie with attribute path=/foo/bar
* Request is /foo/bar?param=value
* Cookie is not send
 
h2. Analysis

It seems that the BasicPathHandler assumes the CookieOrigin::getPath only 
returns the path (without query parameters) which is not the case.


h2. Possible Solution

I think there are two possible solutions

1.) Change BasicPathHandler to support paths containing query parameters
So that this test doesn't fail anymore
{code}
@Test
void testPathMatchWithQueryParams() {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff?foo", 
false);
    final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
    cookie.setPath("/stuff");
    Assertions.assertTrue(h.match(cookie, origin));
}
{code}

2.) Remove query params from the CookieOrigins path.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to