You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Steve Johnson <sj...@mercury.com> on 2004/08/23 22:54:44 UTC

Set-Cookie: filtering on the path= verses URL path

Hi All,
 
We have a URL that works in IE and Netscape, but the cookie is not getting sent
from HTTPClient.
 
Here is the URL and the Set-Cookie
 
https://was4.hewitt.com/insightreporting/reports/websitemonitoring
<https://was4.hewitt.com/insightreporting/reports/websitemonitoring> 
 
response header has this:
 
Set-Cookie: JSESSIONID=0000CQL00NOE2OHVJFC5I3I5YRQ:v0c153k7;Path=/insight
 
The cookie path fails this logic in CookieSpecBase.java
 
    /**
     * Performs a path-match slightly smarter than a straight-forward startsWith
     * check.
     * @param path The path to check.
     * @param topmostPath The path to check against.
     * @return true if the paths match
     */
    private static boolean pathMatch(
        final String path, final String topmostPath) {
            
        boolean match = path.startsWith (topmostPath);     // Our example passes this
        
        // if there is a match and these values are not exactly the same we have
        // to make sure we're not matcing "/foobar" and "/foo"
        if (match && path.length() != topmostPath.length()) {
            if (!topmostPath.endsWith(PATH_DELIM)) {
                match = (path.charAt(topmostPath.length()) == PATH_DELIM_CHAR);  // Our example fails this, we
want /foobar to match /foo
            }
        }
        return match;
    }
 
Is there a way to bypass this pathMatch() or specify another one?
 
Thanks,
Steve
 
Steve Johnson
Software Engineer
Mercury Interactive
720 564 - 6532
USA, Canada and the Americas 
720 564-6620
Hours: M-F 08:00-17:00 MST (Mountain Standard Time) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 <http://www.mercuryinteractive.com> http://www.mercuryinteractive.com
Looking for Answers to your SiteScope or SiteSeer questions?        <http://support.mercuryinteractive.com>
http://support.mercuryinteractive.com
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
 

Re: Set-Cookie: filtering on the path= verses URL path

Posted by Oleg Kalnichevski <ol...@apache.org>.
Steve,
The cookie with the path attribute "/insight" may certainly not be sent
to a url starting with "/insightreporting". So, HttpClient's behavior is
correct.

You can pursue one of three options to work the problem around.

(1) If you do not mind using ALPHA software you can consider using
HttpClient 3.0alpha1, which supports pluggable cookie policies
(2) Fork HttpClient 2.0.1 and tweak its cookie policy(ies) to your
liking
(3) Disable automatic redirect, execute the first GET, iterate through
the cookies in the HTTP state prior to executing the subsequent
requests, find the session cookie and replace its path attribute

Hope this helps,

Oleg


On Mon, 2004-08-23 at 22:54, Steve Johnson wrote:
> Hi All,
>  
> We have a URL that works in IE and Netscape, but the cookie is not getting sent
> from HTTPClient.
>  
> Here is the URL and the Set-Cookie
>  
> https://was4.hewitt.com/insightreporting/reports/websitemonitoring
> <https://was4.hewitt.com/insightreporting/reports/websitemonitoring> 
>  
> response header has this:
>  
> Set-Cookie: JSESSIONID=0000CQL00NOE2OHVJFC5I3I5YRQ:v0c153k7;Path=/insight
>  
> The cookie path fails this logic in CookieSpecBase.java
>  
>     /**
>      * Performs a path-match slightly smarter than a straight-forward startsWith
>      * check.
>      * @param path The path to check.
>      * @param topmostPath The path to check against.
>      * @return true if the paths match
>      */
>     private static boolean pathMatch(
>         final String path, final String topmostPath) {
>             
>         boolean match = path.startsWith (topmostPath);     // Our example passes this
>         
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && path.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith(PATH_DELIM)) {
>                 match = (path.charAt(topmostPath.length()) == PATH_DELIM_CHAR);  // Our example fails this, we
> want /foobar to match /foo
>             }
>         }
>         return match;
>     }
>  
> Is there a way to bypass this pathMatch() or specify another one?
>  
> Thanks,
> Steve
>  
> Steve Johnson
> Software Engineer
> Mercury Interactive
> 720 564 - 6532
> USA, Canada and the Americas 
> 720 564-6620
> Hours: M-F 08:00-17:00 MST (Mountain Standard Time) 
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  <http://www.mercuryinteractive.com> http://www.mercuryinteractive.com
> Looking for Answers to your SiteScope or SiteSeer questions?        <http://support.mercuryinteractive.com>
> http://support.mercuryinteractive.com
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org