Package org.apache.http.message

Examples of org.apache.http.message.BasicHttpEntityEnclosingRequest


        HttpRequest httpRequest;

        if ("POST".equals(httpMethod) || "PUT".equals(httpMethod)) {

            URL url = new URL(epr.getAddress());
            httpRequest = new BasicHttpEntityEnclosingRequest(
                httpMethod,
                msgContext.isPropertyTrue(NhttpConstants.POST_TO_URI) ?
                    epr.getAddress() : url.getPath()
                        + (url.getQuery() != null ? "?" + url.getQuery() : ""),
                msgContext.isPropertyTrue(NhttpConstants.FORCE_HTTP_1_0) ?
View Full Code Here


  if (solrRecord.getWorkspaceName().length() > 0){
    layerName += solrRecord.getWorkspaceName() + ":" + solrRecord.getName();
  } else {
    layerName += solrRecord.getName();
  }
      BasicHttpEntityEnclosingRequest proxyRequest =
          new BasicHttpEntityEnclosingRequest(servletRequest.getMethod(), rewriteUrlFromRequest(layerName, servletRequest));
     
      copyRequestHeaders(servletRequest, proxyRequest);

      // Add the input entity (streamed) then execute the request.
      HttpResponse proxyResponse = null;
      InputStream servletRequestInputStream = servletRequest.getInputStream();
      try {
        try {
          proxyRequest.setEntity(new InputStreamEntity(servletRequestInputStream, servletRequest.getContentLength()));

          // Execute the request
          logger.debug("proxy " + servletRequest.getMethod() + " uri: " + servletRequest.getRequestURI() + " -- " + proxyRequest.getRequestLine().getUri());
          proxyResponse = proxyClient.execute(URIUtils.extractHost(targetUri), proxyRequest);
        } finally {
          closeQuietly(servletRequestInputStream);
        }
View Full Code Here

            int port = ce.getAddressOfRemoteServer().getPort();
            HttpHost host = new HttpHost(hostName, port);
            DefaultHttpClient client = new DefaultHttpClient();
            URL sessionURL = new URL("http://" + hostName + ":" + port
                    + "/grid/api/testsession?session=" + d.getSessionId());
            BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest(
                    "POST", sessionURL.toExternalForm());
            HttpResponse response = client.execute(host, r);
            JsonObject object = extractObject(response);
            URL myURL = new URL(object.getString("proxyId"));
            if ((myURL.getHost() != null) && (myURL.getPort() != -1)) {
View Full Code Here

       * 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, targetUri);
         /*
          * 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, targetUri);
View Full Code Here

     * this header is added automatically for us - so the caching client shouldn't
     * specifically be worried about this requirement.
     */
    @Ignore
    public void testHTTP1_1RequestsWithBodiesOfKnownLengthMustHaveContentLength() throws Exception {
        BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
                HTTP_1_1);
        post.setEntity(mockEntity);

        replayMocks();

        HttpResponse response = impl.execute(host, post);

View Full Code Here

     * specifically be worried about this requirement.
     */
    @Ignore
    public void testHTTP1_1RequestsWithUnknownBodyLengthAreRejectedOrHaveContentLengthAdded()
            throws Exception {
        BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
                HTTP_1_1);

        byte[] bytes = new byte[128];
        (new Random()).nextBytes(bytes);

        HttpEntity mockBody = EasyMock.createMockBuilder(ByteArrayEntity.class).withConstructor(
                new Object[] { bytes }).addMockedMethods("getContentLength").createMock();
        org.easymock.EasyMock.expect(mockBody.getContentLength()).andReturn(-1L).anyTimes();
        post.setEntity(mockBody);

        Capture<HttpRequest> reqCap = new Capture<HttpRequest>();
        org.easymock.EasyMock.expect(
                mockBackend.execute(org.easymock.EasyMock.eq(host), org.easymock.EasyMock
                        .capture(reqCap), (HttpContext) org.easymock.EasyMock.isNull())).andReturn(
View Full Code Here

     *
     * http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.2
     */
    @Test
    public void testOPTIONSRequestsWithBodiesAndNoContentTypeHaveOneSupplied() throws Exception {
        BasicHttpEntityEnclosingRequest options = new BasicHttpEntityEnclosingRequest("OPTIONS",
                "/", HTTP_1_1);
        options.setEntity(body);
        options.setHeader("Content-Length", "1");

        Capture<HttpRequest> reqCap = new Capture<HttpRequest>();
        org.easymock.EasyMock.expect(
                mockBackend.execute(org.easymock.EasyMock.eq(host), org.easymock.EasyMock
                        .capture(reqCap), (HttpContext) org.easymock.EasyMock.isNull())).andReturn(
View Full Code Here

        assertTrue(closed.set || bais.read() == -1);
    }
   
    @Test
    public void consumesBodyOf100ContinueResponseIfItArrives() throws Exception {
        HttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest("POST", "/", HttpVersion.HTTP_1_1);
        int nbytes = 128;
        req.setHeader("Content-Length","" + nbytes);
        req.setHeader("Content-Type", "application/octet-stream");
        HttpEntity postBody = new ByteArrayEntity(HttpTestUtils.getRandomBytes(nbytes));
        req.setEntity(postBody);
       
        HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_CONTINUE, "Continue");
        final Flag closed = new Flag();
        ByteArrayInputStream bais = makeTrackableBody(nbytes, closed);
        resp.setEntity(new InputStreamEntity(bais, -1));
View Full Code Here

     */
    @Test
    public void testResponsesToPOSTWithoutCacheControlOrExpiresAreNotCached() throws Exception {
        emptyMockCacheExpectsNoPuts();

        final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
                HttpVersion.HTTP_1_1);
        post.setHeader("Content-Length", "128");
        post.setEntity(HttpTestUtils.makeBody(128));

        originResponse.removeHeaders("Cache-Control");
        originResponse.removeHeaders("Expires");

        EasyMock.expect(
View Full Code Here

     */
    @Test
    public void testResponsesToPUTsAreNotCached() throws Exception {
        emptyMockCacheExpectsNoPuts();

        final BasicHttpEntityEnclosingRequest put = new BasicHttpEntityEnclosingRequest("PUT", "/",
                HttpVersion.HTTP_1_1);
        put.setEntity(HttpTestUtils.makeBody(128));
        put.addHeader("Content-Length", "128");

        originResponse.setHeader("Cache-Control", "max-age=3600");

        EasyMock.expect(
                mockBackend.execute(
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.