Package org.apache.http

Examples of org.apache.http.HeaderIterator


            new BasicHeader("Name", ",token2"),
            new BasicHeader("Name", " ,token3"),
            new BasicHeader("Name", ", token4"),
            new BasicHeader("Name", " , token5"),
        };
        HeaderIterator hit = new BasicHeaderIterator(headers, null);
        TokenIterator  ti  = new BasicTokenIterator(hit);

        assertTrue(ti.hasNext());
        assertEquals("token0", "token0", ti.nextToken());
        assertTrue(ti.hasNext());
View Full Code Here


            new BasicHeader("Name", "token2,"),
            new BasicHeader("Name", "token3 ,"),
            new BasicHeader("Name", "token4, "),
            new BasicHeader("Name", "token5 , "),
        };
        HeaderIterator hit = new BasicHeaderIterator(headers, null);
        TokenIterator  ti  = new BasicTokenIterator(hit);

        assertTrue(ti.hasNext());
        assertEquals("token0", "token0", ti.nextToken());
        assertTrue(ti.hasNext());
View Full Code Here

    public void testTokenChar() {
        Header[] headers = new Header[]{
            new BasicHeader("Name", "token0")
        };
        HeaderIterator     hit = new BasicHeaderIterator(headers, null);
        BasicTokenIterator bti = new BasicTokenIterator(hit);

        assertTrue ("letter"   , bti.isTokenChar('j'));
        assertFalse("control"  , bti.isTokenChar('\b'));
        assertFalse("separator", bti.isTokenChar('?'));
View Full Code Here

            new BasicHeader("in", "token0=token1"),
            new BasicHeader("no", "token0 token1"),
            new BasicHeader("pre", "<token0,token1"),
            new BasicHeader("post", "token0,token1="),
        };
        HeaderIterator hit = new BasicHeaderIterator(headers, "in");
        TokenIterator  ti  = new BasicTokenIterator(hit);

        // constructor located token0
        assertTrue(ti.hasNext());
        try {
View Full Code Here

            new BasicHeader("Name", " "),
            new BasicHeader("Name", ""),
            new BasicHeader("Name", ","),
            new BasicHeader("Name", " ,, "),
        };
        HeaderIterator hit = new BasicHeaderIterator(headers, null);
        TokenIterator  ti  = new BasicTokenIterator(hit);

        try {
            // call next() instead of nextToken() to get that covered, too
            ti.next();
View Full Code Here

    public void testWrongProtected() {

        Header[] headers = new Header[]{
            new BasicHeader("Name", "token1,token2")
        };
        HeaderIterator     hit = new BasicHeaderIterator(headers, null);
        BasicTokenIterator bti = new BasicTokenIterator(hit);

        try {
            bti.findTokenStart(-1);
            fail("tokenStart: negative index not detected");
View Full Code Here

                ClientContext.COOKIE_ORIGIN);
        if (cookieOrigin == null) {
            LOG.info("CookieOrigin not available in HTTP context");
            return;
        }
        HeaderIterator it = response.headerIterator(SM.SET_COOKIE);
        processCookies(it, cookieSpec, cookieOrigin, cookieStore);
       
        // see if the cookie spec supports cookie versioning.
        if (cookieSpec.getVersion() > 0) {
            // process set-cookie2 headers.
View Full Code Here

                ClientContext.COOKIE_ORIGIN);
        if (cookieOrigin == null) {
            this.log.info("CookieOrigin not available in HTTP context");
            return;
        }
        HeaderIterator it = response.headerIterator(SM.SET_COOKIE);
        processCookies(it, cookieSpec, cookieOrigin, cookieStore);

        // see if the cookie spec supports cookie versioning.
        if (cookieSpec.getVersion() > 0) {
            // process set-cookie2 headers.
View Full Code Here

    }


    public void testInvalid() {

        HeaderIterator hit = null;
        try {
            hit = new BasicHeaderIterator(null, "whatever");
            fail("null headers not detected");
        } catch (IllegalArgumentException iax) {
            // expected
        }

        // this is not invalid
        hit = new BasicHeaderIterator(new Header[0], "whatever");
        assertFalse(hit.hasNext());

        // but this is
        try {
            hit.nextHeader();
            fail("next beyond end not detected");
        } catch (NoSuchElementException nsx) {
            // expected
        }
    }
View Full Code Here

            new BasicHeader("naMe", "value2=whatever"),
            new BasicHeader("namE", "value3;tag=nil"),
        };

        // without filter, using plain next()
        HeaderIterator hit = new BasicHeaderIterator(headers, null);
        assertTrue(hit.hasNext());
        assertEquals("0", headers[0], hit.next());
        assertTrue(hit.hasNext());
        assertEquals("1", headers[1], hit.next());
        assertTrue(hit.hasNext());
        assertEquals("2", headers[2], hit.next());
        assertTrue(hit.hasNext());
        assertEquals("3", headers[3], hit.next());
        assertFalse(hit.hasNext());

        hit = new BasicHeaderIterator(headers, null);
        assertTrue(hit.hasNext());
        try {
            hit.remove();
            fail("remove not detected");
        } catch (UnsupportedOperationException uox) {
            // expected
        }
View Full Code Here

TOP

Related Classes of org.apache.http.HeaderIterator

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.