Package org.apache.http

Examples of org.apache.http.HttpMessage.addHeader()


        ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
        HttpMessage message = new HttpMessageMockup();

        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
        message.addHeader("Content-Length", "xxx");
        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
       
        // strict mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
View Full Code Here


        HttpMessage message = new HttpMessageMockup();

        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
        message.addHeader("Content-Length", "xxx");
        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
       
        // strict mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
        try {
View Full Code Here

    public void testBasicHeaderOps() {
        HttpMessage message = new HttpMessageMockup();
        assertFalse(message.containsHeader("whatever"));
       
        message.addHeader("name", "1");
        message.addHeader("name", "2");
       
        Header[] headers = message.getAllHeaders();
        assertNotNull(headers);
        assertEquals(2, headers.length);
View Full Code Here

    public void testBasicHeaderOps() {
        HttpMessage message = new HttpMessageMockup();
        assertFalse(message.containsHeader("whatever"));
       
        message.addHeader("name", "1");
        message.addHeader("name", "2");
       
        Header[] headers = message.getAllHeaders();
        assertNotNull(headers);
        assertEquals(2, headers.length);
       
View Full Code Here

        h = message.getLastHeader("name");
        assertNotNull(h);
        assertEquals("2", h.getValue());
       
        // Should have no effect
        message.addHeader(null);
        message.setHeader(null);
       
        headers = message.getHeaders("name");
        assertNotNull(headers);
        assertEquals(2, headers.length);
View Full Code Here

        assertNotNull(headers);
        assertEquals(2, headers.length);
        assertEquals("3", headers[0].getValue());
        assertEquals("2", headers[1].getValue());

        message.addHeader("name", "4");
       
        headers[1] = new BasicHeader("name", "5");
        message.setHeaders(headers);
       
        headers = message.getHeaders("name");
View Full Code Here

            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            message.addHeader(null, null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
View Full Code Here

    }

    public void testEntityWithChunkTransferEncoding() throws Exception {
        ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Chunked");

        assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
View Full Code Here

    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
        ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Identity");

        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
    }
   
    public void testEntityWithInvalidTransferEncoding() throws Exception {
View Full Code Here

    }
   
    public void testEntityWithInvalidTransferEncoding() throws Exception {
        ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "whatever");

        try {
            lenStrategy.determineLength(message);
            fail("ProtocolException should have been thrown");
        } catch (ProtocolException ex) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.