Package org.apache.http.message

Examples of org.apache.http.message.BasicHttpEntityEnclosingRequest


        testOrderOfMultipleHeadersIsPreservedOnRequests("Content-Encoding", HttpRequestWrapper.wrap(post));
    }

    @Test
    public void testOrderOfMultipleContentLanguageHeadersIsPreservedOnRequests() throws Exception {
        final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
                HttpVersion.HTTP_1_1);
        post.setEntity(body);
        post.addHeader("Content-Language", "mi");
        post.addHeader("Content-Language", "en");
        post.addHeader("Content-Length", "128");
        testOrderOfMultipleHeadersIsPreservedOnRequests("Content-Language", HttpRequestWrapper.wrap(post));
    }
View Full Code Here


        testOrderOfMultipleHeadersIsPreservedOnRequests("Content-Language", HttpRequestWrapper.wrap(post));
    }

    @Test
    public void testOrderOfMultipleExpectHeadersIsPreservedOnRequests() throws Exception {
        final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
                HttpVersion.HTTP_1_1);
        post.setEntity(body);
        post.addHeader("Expect", "100-continue");
        post.addHeader("Expect", "x-expect=true");
        post.addHeader("Content-Length", "128");
        testOrderOfMultipleHeadersIsPreservedOnRequests("Expect", HttpRequestWrapper.wrap(post));
    }
View Full Code Here

     *
     * http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3
     */
    @Test
    public void testRequestsExpecting100ContinueBehaviorShouldSetExpectHeader() throws Exception {
        final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest(
                "POST", "/", HttpVersion.HTTP_1_1);
        post.setHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
        post.setHeader("Content-Length", "128");
        post.setEntity(new BasicHttpEntity());

        final Capture<HttpRequestWrapper> reqCap = new Capture<HttpRequestWrapper>();

        EasyMock.expect(
                mockBackend.execute(
View Full Code Here

     * http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3
     */
    @Test
    public void testRequestsNotExpecting100ContinueBehaviorShouldNotSetExpectContinueHeader()
            throws Exception {
        final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest(
                "POST", "/", HttpVersion.HTTP_1_1);
        post.setHeader("Content-Length", "128");
        post.setEntity(new BasicHttpEntity());

        final Capture<HttpRequestWrapper> reqCap = new Capture<HttpRequestWrapper>();

        EasyMock.expect(
                mockBackend.execute(
View Full Code Here

     */
    @Test
    public void test100ContinueResponsesAreNotForwardedTo1_0ClientsWhoDidNotAskForThem()
            throws Exception {

        final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
                new ProtocolVersion("HTTP", 1, 0));
        post.setEntity(body);
        post.setHeader("Content-Length", "128");

        originResponse = Proxies.enhanceResponse(
                new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue"));
        EasyMock.expect(
                mockBackend.execute(
View Full Code Here

            for (int i = 0; i < requestBodies.length; i++) {
                if (!conn.isOpen()) {
                    Socket socket = new Socket(host.getHostName(), host.getPort());
                    conn.bind(socket, params);
                }
                BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
                        "/servlets-examples/servlet/RequestInfoExample");
                request.setEntity(requestBodies[i]);
                System.out.println(">> Request URI: " + request.getRequestLine().getUri());

                context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
                request.setParams(params);
                httpexecutor.preProcess(request, httpproc, context);
                HttpResponse response = httpexecutor.execute(request, conn, context);
                httpexecutor.postProcess(response, httpproc, context);
               
                System.out.println("<< Response: " + response.getStatusLine());
View Full Code Here

        }
    }
   
    public void testRequestContentProtocolException() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        BasicHttpRequest request1 = new BasicHttpEntityEnclosingRequest("POST", "/");
        request1.addHeader(new BasicHeader(HTTP.TRANSFER_ENCODING, "chunked"));
        BasicHttpRequest request2 = new BasicHttpEntityEnclosingRequest("POST", "/");
        request2.addHeader(new BasicHeader(HTTP.CONTENT_LEN, "12"));

        RequestContent interceptor = new RequestContent();
        try {
            interceptor.process(request1, context);
            fail("ProtocolException should have been thrown");
View Full Code Here

        }
   }
   
    public void testRequestContentNullEntity() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        BasicHttpRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");

        RequestContent interceptor = new RequestContent();
        interceptor.process(request, context);
        Header header = request.getFirstHeader(HTTP.CONTENT_LEN);
        assertNotNull(header);
        assertEquals("0", header.getValue());
        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
   }
View Full Code Here

        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
   }
   
    public void testRequestContentEntityContentLengthDelimitedHTTP11() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        String s = "whatever";
        StringEntity entity = new StringEntity(s, "US-ASCII");
        request.setEntity(entity);

        RequestContent interceptor = new RequestContent();
        interceptor.process(request, context);
        Header header = request.getFirstHeader(HTTP.CONTENT_LEN);
        assertNotNull(header);
        assertEquals(s.length(), Integer.parseInt(header.getValue()));
        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
   }
View Full Code Here

        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
   }
   
    public void testRequestContentEntityChunkedHTTP11() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        String s = "whatever";
        StringEntity entity = new StringEntity(s, "US-ASCII");
        entity.setChunked(true);
        request.setEntity(entity);

        RequestContent interceptor = new RequestContent();
        interceptor.process(request, context);
        Header header = request.getFirstHeader(HTTP.TRANSFER_ENCODING);
        assertNotNull(header);
        assertEquals("chunked", header.getValue());
        assertNull(request.getFirstHeader(HTTP.CONTENT_LEN));
   }
View Full Code Here

TOP

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

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.