Package org.apache.http.message

Examples of org.apache.http.message.BasicHeader


    public void testCookieStandardCompliantParsingLocalHost() throws Exception {
        CookieSpec cookiespec = new BestMatchSpec();
        CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);

        Header header = new BasicHeader("Set-Cookie", "special=\"abcdigh\"; Version=1");

        List<Cookie> cookies = cookiespec.parse(header, origin);
        for (int i = 0; i < cookies.size(); i++) {
            Cookie cookie = cookies.get(i);
            cookiespec.validate(cookie, origin);
View Full Code Here


    public void testCookieStandardCompliantParsingLocalHost2() throws Exception {
        CookieSpec cookiespec = new BestMatchSpec();
        CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);

        Header header = new BasicHeader("Set-Cookie2", "special=\"abcdigh\"; Version=1");

        List<Cookie> cookies = cookiespec.parse(header, origin);
        for (int i = 0; i < cookies.size(); i++) {
            Cookie cookie = cookies.get(i);
            cookiespec.validate(cookie, origin);
View Full Code Here

            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            cookiespec.parse(new BasicHeader("Set-Cookie", "name=value"), null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
View Full Code Here

            HttpMultipartMode mode,
            final String boundary,
            final Charset charset) {
        super();
        this.multipart = new HttpMultipart("form-data");
        this.contentType = new BasicHeader(
                HTTP.CONTENT_TYPE,
                generateContentType(boundary, charset));
        this.dirty = true;
       
        this.message = new Message();
View Full Code Here

     * Test parsing cookie <tt>"Path"</tt> attribute.
     */
    public void testParsePath() throws Exception {
        CookieSpec cookiespec = new RFC2965Spec();
        CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        Header header = new BasicHeader("Set-Cookie2", "name=value;Path=/;Version=1;Path=");
        List<Cookie> cookies = cookiespec.parse(header, origin);
        assertNotNull(cookies);
        assertEquals(1, cookies.size());
        // only the first occurrence of path attribute is considered, others ignored
        ClientCookie cookie = (ClientCookie) cookies.get(0);
View Full Code Here

    public void testParsePathDefault() throws Exception {
        CookieSpec cookiespec = new RFC2965Spec();
        CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/path/", false);
        // Path is OPTIONAL, defaults to the request path
        Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
        List<Cookie> cookies = cookiespec.parse(header, origin);
        assertNotNull(cookies);
        assertEquals(1, cookies.size());
        ClientCookie cookie = (ClientCookie) cookies.get(0);
        assertEquals("/path", cookie.getPath());
View Full Code Here

    }

    public void testParseNullPath() throws Exception {
        CookieSpec cookiespec = new RFC2965Spec();
        CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        Header header = new BasicHeader("Set-Cookie2", "name=value;Path=;Version=1");
        List<Cookie> cookies = cookiespec.parse(header, origin);
        assertNotNull(cookies);
        assertEquals(1, cookies.size());
        ClientCookie cookie = (ClientCookie) cookies.get(0);
        assertEquals("/", cookie.getPath());
View Full Code Here

    }

    public void testParseBlankPath() throws Exception {
        CookieSpec cookiespec = new RFC2965Spec();
        CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        Header header = new BasicHeader("Set-Cookie2", "name=value;Path=\"   \";Version=1");
        List<Cookie> cookies = cookiespec.parse(header, origin);
        assertNotNull(cookies);
        assertEquals(1, cookies.size());
        ClientCookie cookie = (ClientCookie) cookies.get(0);
        assertEquals("/", cookie.getPath());
View Full Code Here

     * Test parsing cookie <tt>"Domain"</tt> attribute.
     */
    public void testParseDomain() throws Exception {
        CookieSpec cookiespec = new RFC2965Spec();
        CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        Header header = new BasicHeader("Set-Cookie2", "name=value;Domain=.domain.com;Version=1;Domain=");
        List<Cookie> cookies = cookiespec.parse(header, origin);
        assertNotNull(cookies);
        assertEquals(1, cookies.size());
        // only the first occurrence of domain attribute is considered, others ignored
        ClientCookie cookie = (ClientCookie) cookies.get(0);
        assertEquals(".domain.com", cookie.getDomain());
        assertTrue(cookie.containsAttribute(ClientCookie.DOMAIN_ATTR));

        // should put a leading dot if there is no dot in front of domain
        header = new BasicHeader("Set-Cookie2", "name=value;Domain=domain.com;Version=1");
        cookies = cookiespec.parse(header, origin);
        assertNotNull(cookies);
        assertEquals(1, cookies.size());
        cookie = (ClientCookie) cookies.get(0);
        assertEquals(".domain.com", cookie.getDomain());
View Full Code Here

    public void testParseDomainDefaultValue() throws Exception {
        CookieSpec cookiespec = new RFC2965Spec();
        CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
        // Domain is OPTIONAL, defaults to the request host
        Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
        List<Cookie> cookies = cookiespec.parse(header, origin);
        assertNotNull(cookies);
        assertEquals(1, cookies.size());
        ClientCookie cookie = (ClientCookie) cookies.get(0);
        assertEquals("www.domain.com", cookie.getDomain());
View Full Code Here

TOP

Related Classes of org.apache.http.message.BasicHeader

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.