Package org.apache.http

Examples of org.apache.http.HttpEntityEnclosingRequest


    new RequestUtils();
  }
 
  @Test
  public void testSetParameters() throws Exception {
    HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/test.html");
    request.setEntity(new StringEntity("<html></html>"));
    RequestUtils.setParameters(request, context, "UTF-8");
  }
View Full Code Here


    assertEquals("http://example.com", url)
  }
 
  @Test
  public void testGetInputStream() throws IOException {
    HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/test.html");
    request.setEntity(new StringEntity("<html></html>"));
    assertNotNull(RequestUtils.getInputStream(request));
   
    HttpEntityEnclosingRequest request2 = new BasicHttpEntityEnclosingRequest("POST", "/test.html");
    assertNull(RequestUtils.getInputStream(request2));
   
    HttpRequest request3 = new BasicHttpRequest("POST", "/test.html");
    assertNull(RequestUtils.getInputStream(request3));
  }
View Full Code Here

        impl.execute(route, HttpRequestWrapper.wrap(trace));
        verifyMocks();

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

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

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

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

        testRequestWithWeakETagValidatorIsNotAllowed("If-Match");
    }

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

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

        unsafeReq.setHeader("Location","http://bar.example.com/content");
        testUnsafeMethodDoesNotInvalidateCacheForHeaderUri(unsafeReq);
    }

    protected HttpRequestWrapper makeRequestWithBody(final String method, final String requestUri) {
        final HttpEntityEnclosingRequest request =
            new BasicHttpEntityEnclosingRequest(method, requestUri, HttpVersion.HTTP_1_1);
        final int nbytes = 128;
        request.setEntity(HttpTestUtils.makeBody(nbytes));
        request.setHeader("Content-Length",""+nbytes);
        return HttpRequestWrapper.wrap(request);
    }
View Full Code Here

    }

    @Test
    public void testPOSTRequestsAreWrittenThroughToOrigin()
        throws Exception {
        final HttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest("POST","/",HttpVersion.HTTP_1_1);
        req.setEntity(HttpTestUtils.makeBody(128));
        req.setHeader("Content-Length","128");
        testRequestIsWrittenThroughToOrigin(req);
    }
View Full Code Here

    }

    @Test
    public void testPUTRequestsAreWrittenThroughToOrigin()
        throws Exception {
        final HttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest("PUT","/",HttpVersion.HTTP_1_1);
        req.setEntity(HttpTestUtils.makeBody(128));
        req.setHeader("Content-Length","128");
        testRequestIsWrittenThroughToOrigin(req);
    }
View Full Code Here

        verifyMocks();
    }

    @Test
    public void testInvalidatesUrisInContentLocationHeadersOnPUTs() throws Exception {
        final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("PUT","/",HTTP_1_1);
        request.setEntity(HttpTestUtils.makeBody(128));
        request.setHeader("Content-Length","128");

        final String contentLocation = "http://foo.example.com/content";
        request.setHeader("Content-Location", contentLocation);

        final String theUri = "http://foo.example.com:80/";
        cacheEntryHasVariantMap(new HashMap<String,String>());

        cacheReturnsEntryForUri(theUri);
View Full Code Here

        verifyMocks();
    }

    @Test
    public void testInvalidatesUrisInLocationHeadersOnPUTs() throws Exception {
        final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("PUT","/",HTTP_1_1);
        request.setEntity(HttpTestUtils.makeBody(128));
        request.setHeader("Content-Length","128");

        final String contentLocation = "http://foo.example.com/content";
        request.setHeader("Location",contentLocation);

        final String theUri = "http://foo.example.com:80/";
        cacheEntryHasVariantMap(new HashMap<String,String>());

        cacheReturnsEntryForUri(theUri);
View Full Code Here

TOP

Related Classes of org.apache.http.HttpEntityEnclosingRequest

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.