Package org.apache.http

Examples of org.apache.http.Header


    public void testNetscapeCookieParsing() throws Exception {
        CookieSpec cookiespec = new BestMatchSpec();
        CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);

        Header header = new BasicHeader("Set-Cookie",
            "name=value; path=/; domain=.mydomain.com; expires=Thu, 01-Jan-2070 00:00:10 GMT; comment=no_comment");
        List<Cookie> cookies = cookiespec.parse(header, origin);
        cookiespec.validate(cookies.get(0), origin);
       
        header = new BasicHeader("Set-Cookie",
View Full Code Here


        CookieSpec cookiespec = new BestMatchSpec();
        CookieOrigin origin = new CookieOrigin("a.b.domain.com", 80, "/", false);

        // Make sure the strict (RFC2965) cookie parsing
        // and validation is used for version 1 Set-Cookie2 headers
        Header header = new BasicHeader("Set-Cookie2", "name=value;path=/;domain=b.domain.com; version=1");

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

    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

       
        List<Header> headers = cookiespec.formatCookies(cookies);
        assertNotNull(headers);
        assertEquals(1, headers.size());
       
        Header header = headers.get(0);
        assertEquals("name1=value1; name2=value2", header.getValue());
       
    }
View Full Code Here

       
        List<Header> headers = cookiespec.formatCookies(cookies);
        assertNotNull(headers);
        assertEquals(1, headers.size());
       
        Header header = headers.get(0);
        assertEquals("$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".domain.com\"; " +
                "name2=\"value2\"; $Path=\"/\"; $Domain=\".domain.com\"",
                header.getValue());
       
    }
View Full Code Here

                ExecutionContext.HTTP_REQUEST);

        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());

        Header header = reqWrapper.getFirstHeader(HTTP.USER_AGENT);
        assertEquals("my-test-client", header.getValue());           
    }
View Full Code Here

            final HttpContext context) throws ProtocolException {
        if (response == null) {
            throw new IllegalArgumentException("HTTP response may not be null");
        }
        //get the location header to find out where to redirect to
        Header locationHeader = response.getFirstHeader("location");
        if (locationHeader == null) {
            // got a redirect response, but no location header
            throw new ProtocolException(
                    "Received redirect response " + response.getStatusLine()
                    + " but no location header");
        }
        String location = locationHeader.getValue();
        if (this.log.isDebugEnabled()) {
            this.log.debug("Redirect requested to location '" + location + "'");
        }

        URI uri;
View Full Code Here

    public void setEntity(final HttpEntity entity) {
        this.entity = entity;
    }
   
    public boolean expectContinue() {
        Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE);
        return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
    }
View Full Code Here

    public static List <NameValuePair> parse (
            final HttpEntity entity) throws IOException {
        List <NameValuePair> result = Collections.emptyList();
        if (isEncoded(entity)) {
            final String content = EntityUtils.toString(entity);
            final Header encoding = entity.getContentEncoding();
            if (content != null && content.length() > 0) {
                result = new ArrayList <NameValuePair>();
                parse(result, new Scanner(content),
                        encoding != null ? encoding.getValue() : null);
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.http.Header

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.