Package org.apache.http.cookie

Examples of org.apache.http.cookie.ClientCookie


        // Domain is OPTIONAL, defaults to the request host
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        Assert.assertEquals("www.domain.com", cookie.getDomain());
        Assert.assertFalse(cookie.containsAttribute(ClientCookie.DOMAIN_ATTR));
    }
View Full Code Here


        final Header header = new BasicHeader("Set-Cookie2", "name=value;Port=\"80,800,8000\";Version=1;Port=nonsense");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        // only the first occurrence of port attribute is considered, others ignored
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        final int[] ports = cookie.getPorts();
        Assert.assertNotNull(ports);
        Assert.assertEquals(3, ports.length);
        Assert.assertEquals(80, ports[0]);
        Assert.assertEquals(800, ports[1]);
        Assert.assertEquals(8000, ports[2]);
        Assert.assertTrue(cookie.containsAttribute(ClientCookie.PORT_ATTR));
    }
View Full Code Here

        // Port is OPTIONAL, cookie can be accepted from any port
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        Assert.assertFalse(cookie.containsAttribute(ClientCookie.PORT_ATTR));
    }
View Full Code Here

        // null port defaults to request port
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Port=;Version=1");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        final int[] ports = cookie.getPorts();
        Assert.assertNotNull(ports);
        Assert.assertEquals(1, ports.length);
        Assert.assertEquals(80, ports[0]);
        Assert.assertEquals("", cookie.getAttribute(ClientCookie.PORT_ATTR));
    }
View Full Code Here

        // blank port defaults to request port
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Port=\"  \";Version=1");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        final int[] ports = cookie.getPorts();
        Assert.assertNotNull(ports);
        Assert.assertEquals(1, ports.length);
        Assert.assertEquals(80, ports[0]);
        Assert.assertEquals("  ", cookie.getAttribute(ClientCookie.PORT_ATTR));
    }
View Full Code Here

        final CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1;");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        Assert.assertEquals("name", cookie.getName());
        Assert.assertEquals("value", cookie.getValue());
    }
View Full Code Here

        final CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1;");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        Assert.assertEquals(1, cookie.getVersion());
        Assert.assertTrue(cookie.containsAttribute(ClientCookie.VERSION_ATTR));
    }
View Full Code Here

        final Header header = new BasicHeader("Set-Cookie2", "name=value;Max-age=3600;Version=1;Max-age=nonsense");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        // only the first occurence of max-age attribute is considered, others ignored
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        Assert.assertFalse(cookie.isExpired(new Date()));
    }
View Full Code Here

        // Max-age is OPTIONAL, defaults to session cookie
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        Assert.assertFalse(cookie.isPersistent());
    }
View Full Code Here

        final CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        final Header header = new BasicHeader("Set-Cookie2", "name=value;Secure;Version=1");
        final List<Cookie> cookies = cookiespec.parse(header, origin);
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final ClientCookie cookie = (ClientCookie) cookies.get(0);
        Assert.assertTrue(cookie.isSecure());
    }
View Full Code Here

TOP

Related Classes of org.apache.http.cookie.ClientCookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.