Examples of HttpEntityEnclosingRequest


Examples of org.apache.http.HttpEntityEnclosingRequest

    String proxyRequestUri = rewriteUrlFromRequest(servletRequest);
    HttpRequest proxyRequest;
    //spec: RFC 2616, sec 4.3: either of these two headers signal that there is a message body.
    if (servletRequest.getHeader(HttpHeaders.CONTENT_LENGTH) != null ||
        servletRequest.getHeader(HttpHeaders.TRANSFER_ENCODING) != null) {
      HttpEntityEnclosingRequest eProxyRequest = new BasicHttpEntityEnclosingRequest(method, proxyRequestUri);
      // Add the input entity (streamed)
      //  note: we don't bother ensuring we close the servletInputStream since the container handles it
      eProxyRequest.setEntity(new InputStreamEntity(servletRequest.getInputStream(), servletRequest.getContentLength()));
      proxyRequest = eProxyRequest;
    } else
      proxyRequest = new BasicHttpRequest(method, proxyRequestUri);

    copyRequestHeaders(servletRequest, proxyRequest);
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

            if (decoder.isCompleted()) {
                // Request entity has been fully received
                connState.setInputState(ServerConnState.REQUEST_BODY_DONE);

                // Create a wrapper entity instead of the original one
                HttpEntityEnclosingRequest entityReq = (HttpEntityEnclosingRequest) request;
                if (entityReq.getEntity() != null) {
                    entityReq.setEntity(new ContentBufferEntity(
                            entityReq.getEntity(),
                            connState.getInbuffer()));
                }
                conn.suspendInput();
                processRequest(conn, request);
            }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

    }

    private boolean originalRequestDidNotExpectContinue(RequestWrapper request) {

        try {
            HttpEntityEnclosingRequest original = (HttpEntityEnclosingRequest) request
                    .getOriginal();

            return !original.expectContinue();
        } catch (ClassCastException ex) {
            return false;
        }
    }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

        verifyMocks();

        HttpRequest forwarded = reqCap.getValue();
        Assert.assertTrue(forwarded instanceof HttpEntityEnclosingRequest);
        HttpEntityEnclosingRequest reqWithBody = (HttpEntityEnclosingRequest) forwarded;
        HttpEntity reqBody = reqWithBody.getEntity();
        Assert.assertNotNull(reqBody);
        Assert.assertNotNull(reqBody.getContentType());
    }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

        impl.execute(host, post);

        verifyMocks();
        EasyMock.verify(post);

        HttpEntityEnclosingRequest forwarded = reqCap.getValue();
        Assert.assertTrue(forwarded.expectContinue());
        boolean foundExpect = false;
        for (Header h : forwarded.getHeaders("Expect")) {
            for (HeaderElement elt : h.getElements()) {
                if ("100-continue".equalsIgnoreCase(elt.getName())) {
                    foundExpect = true;
                    break;
                }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

        impl.execute(host, post);

        verifyMocks();
        EasyMock.verify(post);

        HttpEntityEnclosingRequest forwarded = reqCap.getValue();
        Assert.assertFalse(forwarded.expectContinue());
        boolean foundExpect = false;
        for (Header h : forwarded.getHeaders("Expect")) {
            for (HeaderElement elt : h.getElements()) {
                if ("100-continue".equalsIgnoreCase(elt.getName())) {
                    foundExpect = true;
                    break;
                }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

        impl.execute(host, trace);
        verifyMocks();

        HttpRequest forwarded = reqCap.getValue();
        if (forwarded instanceof HttpEntityEnclosingRequest) {
            HttpEntityEnclosingRequest bodyReq = (HttpEntityEnclosingRequest) forwarded;
            Assert.assertTrue(bodyReq.getEntity() == null
                    || bodyReq.getEntity().getContentLength() == 0);
        } else {
            // request didn't enclose an entity
        }
    }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

        Assert.assertTrue(response.getStatusLine().getStatusCode() == HttpStatus.SC_BAD_REQUEST);
    }

    @Test
    public void testPUTWithIfMatchWeakETagIsNotAllowed() throws Exception {
        HttpEntityEnclosingRequest put = new BasicHttpEntityEnclosingRequest("PUT", "/", HTTP_1_1);
        put.setEntity(makeBody(128));
        put.setHeader("Content-Length", "128");
        put.setHeader("If-Match", "W/\"etag\"");
        request = put;

        testRequestWithWeakETagValidatorIsNotAllowed("If-Match");
    }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

        testRequestWithWeakETagValidatorIsNotAllowed("If-Match");
    }

    @Test
    public void testPUTWithIfNoneMatchWeakETagIsNotAllowed() throws Exception {
        HttpEntityEnclosingRequest put = new BasicHttpEntityEnclosingRequest("PUT", "/", HTTP_1_1);
        put.setEntity(makeBody(128));
        put.setHeader("Content-Length", "128");
        put.setHeader("If-None-Match", "W/\"etag\"");
        request = put;

        testRequestWithWeakETagValidatorIsNotAllowed("If-None-Match");
    }
View Full Code Here

Examples of org.apache.http.HttpEntityEnclosingRequest

        HttpResponse response;

        try {

            if (request instanceof HttpEntityEnclosingRequest) {
                HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) request;
                if (entityRequest.expectContinue()) {
                    response = this.responseFactory.newHttpResponse(
                            ver, HttpStatus.SC_CONTINUE, context);
                    response.setParams(
                            new DefaultedHttpParams(response.getParams(), this.params));

                    if (this.expectationVerifier != null) {
                        try {
                            this.expectationVerifier.verify(request, response, context);
                        } catch (HttpException ex) {
                            response = this.responseFactory.newHttpResponse(
                                    HttpVersion.HTTP_1_0,
                                    HttpStatus.SC_INTERNAL_SERVER_ERROR,
                                    context);
                            response.setParams(
                                    new DefaultedHttpParams(response.getParams(), this.params));
                            handleException(ex, response);
                        }
                    }

                    if (response.getStatusLine().getStatusCode() < 200) {
                        // Send 1xx response indicating the server expections
                        // have been met
                        conn.submitResponse(response);
                    } else {
                        conn.resetInput();
                        sendResponse(conn, request, response);
                    }
                }
                // Request content is expected.
                ConsumingNHttpEntity consumingEntity = null;

                // Lookup request handler for this request
                if (requestHandler != null) {
                    consumingEntity = requestHandler.entityRequest(entityRequest, context);
                }
                if (consumingEntity == null) {
                    consumingEntity = new NullNHttpEntity(entityRequest.getEntity());
                }
                entityRequest.setEntity(consumingEntity);
                connState.setConsumingEntity(consumingEntity);

            } else {
                // No request content is expected.
                // Process request right away
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.