[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981769#action_12981769
 ] 

Dmitry Grytsovets edited comment on HTTPCLIENT-1043 at 1/14/11 9:39 AM:
------------------------------------------------------------------------

       @Test
        public void testCookieReadAndSend() throws Exception {
                BasicHeader header = new BasicHeader("Set-Cookie",
                                "cookie-name=cookie-value; domain=127.0.0.1; 
path=/d1/d2");

                CookieSpec cookiespec = new RFC2109Spec();
                CookieOrigin readOrigin = new CookieOrigin("127.0.0.1", 80, 
"/d1", false);
                //this part must be fixed  
                List<Cookie> cookies = cookiespec.parse(header, readOrigin);
                try {
                        for (int i = 0; i < cookies.size(); i++) {
                                cookiespec.validate(cookies.get(i), readOrigin);
                        }
                } catch (MalformedCookieException e) {
                        Assert.fail("MalformedCookieException exception should 
havn't been thrown");
                }
                //next part  works now
                try {
                        CookieOrigin sendOrigin = new CookieOrigin("127.0.0.1", 
80, "/d1/d2/d3/", false);
                        for (int i = 0; i < cookies.size(); i++) {
                                cookiespec.validate(cookies.get(i), sendOrigin);
                        }
                } catch (MalformedCookieException e) {
                        Assert.fail("MalformedCookieException exception should 
havn't been thrown");
                }


        }



      was (Author: dgreen):
           @Test
        public void testCookieReadAndSend() throws Exception {
                BasicHeader header = new BasicHeader("Set-Cookie",
                                "cookie-name=cookie-value; domain=127.0.0.1; 
path=/d1/d2");

                CookieSpec cookiespec = new RFC2109Spec();
                CookieOrigin readOrigin = new CookieOrigin("127.0.0.1", 80, 
"/d1", false);
                //this part must be fixed  
                List<Cookie> cookies = cookiespec.parse(header, readOrigin);
                try {
                        for (int i = 0; i < cookies.size(); i++) {
                                cookiespec.validate(cookies.get(i), readOrigin);
                        }
                } catch (MalformedCookieException e) {
                        Assert.fail("MalformedCookieException exception should 
havn't been thrown");
                }
                //next part  works now
                try {
                        CookieOrigin sendOrigin = new CookieOrigin("127.0.0.1", 
80, "/d1/d2/d3/", false);
                        for (int i = 0; i < cookies.size(); i++) {
                                cookiespec.validate(cookies.get(i), readOrigin);
                        }
                } catch (MalformedCookieException e) {
                        Assert.fail("MalformedCookieException exception should 
havn't been thrown");
                }


        }


  
> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>             Fix For: 4.1.0, Future
>
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // 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 && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // 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 && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to