Package org.apache.http.message

Examples of org.apache.http.message.BasicHttpResponse.addHeader()


    public void testMultipleAllows() {
        ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1);
        BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
        BasicHttpResponse resp = new BasicHttpResponse(line);
        resp.addHeader("Allow", "POST");
        resp.addHeader("Allow", "GET");

        HttpOptions opt = new HttpOptions();
        Set<String> methodsName = opt.getAllowedMethods(resp);
       
        assertTrue(methodsName.contains("POST"));
View Full Code Here


    @Test
    public void testProduceOutputLongChunkedMessage() throws Exception {
        conn = new DefaultNHttpServerConnection(session, 64);

        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
        final NStringEntity entity = new NStringEntity("a lot of various stuff");
        entity.setChunked(true);
        response.setEntity(entity);

        final WritableByteChannelMock wchannel = Mockito.spy(new WritableByteChannelMock(64));
View Full Code Here

    @Test
    public void testProduceOutputLongChunkedMessageSaturatedChannel() throws Exception {
        conn = new DefaultNHttpServerConnection(session, 64);

        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
        final NStringEntity entity = new NStringEntity("a lot of various stuff");
        entity.setChunked(true);
        response.setEntity(entity);

        final WritableByteChannelMock wchannel = Mockito.spy(new WritableByteChannelMock(64, 64));
View Full Code Here

        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testChunkedContent() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        assertTrue(reuseStrategy.keepAlive(response, context));
    }

    public void testIgnoreInvalidKeepAlive() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
View Full Code Here

        assertTrue(reuseStrategy.keepAlive(response, context));
    }

    public void testIgnoreInvalidKeepAlive() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Connection", "keep-alive");

        assertFalse(reuseStrategy.keepAlive(response, context));
    }

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

    }

    public void testExplicitClose() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        response.addHeader("Connection", "close");

        assertFalse(reuseStrategy.keepAlive(response, context));
    }
View Full Code Here

    public void testExplicitClose() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        response.addHeader("Connection", "close");

        assertFalse(reuseStrategy.keepAlive(response, context));
    }

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

    }

    public void testExplicitKeepAlive() throws Exception {
        // Use HTTP 1.0
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Content-Length", "10");
        response.addHeader("Connection", "keep-alive");

        assertTrue(reuseStrategy.keepAlive(response, context));
    }
View Full Code Here

    public void testExplicitKeepAlive() throws Exception {
        // Use HTTP 1.0
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Content-Length", "10");
        response.addHeader("Connection", "keep-alive");

        assertTrue(reuseStrategy.keepAlive(response, context));
    }

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

        assertTrue(reuseStrategy.keepAlive(response, context));
    }

    public void testHTTP10Default() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Content-Length", "10");
        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testHTTP11Default() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
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.