Package org.apache.http.entity

Examples of org.apache.http.entity.InputStreamEntity


         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


                            compressor.finish();
                            byte[] output = new byte[100];
                            int compressedLength = compressor.deflate(output);
                            byte[] compressed = new byte[compressedLength];
                            System.arraycopy(output, 0, compressed, 0, compressedLength);
                            response.setEntity(new InputStreamEntity(
                                    new ByteArrayInputStream(compressed), compressedLength));
                            return;
                        }
                    }
                }
View Full Code Here

                            }

                            out.close();

                            byte[] arr = bytes.toByteArray();
                            response.setEntity(new InputStreamEntity(new ByteArrayInputStream(arr),
                                    arr.length));

                            return;
                        }
                    }
View Full Code Here

        });
        HttpContext context = new BasicHttpContext();

        String s = "http://localhost:" + port;
        HttpPost httppost = new HttpPost(s);
        httppost.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));

        try {
View Full Code Here

              for (ContentStream content : streams) {
                contentStream[0] = content;
                break;
              }
              if (contentStream[0] instanceof RequestWriter.LazyContentStream) {
                post.setEntity(new InputStreamEntity(contentStream[0].getStream(), -1) {
                  @Override
                  public Header getContentType() {
                    return new BasicHeader("Content-Type", contentStream[0].getContentType());
                  }
                 
                  @Override
                  public boolean isRepeatable() {
                    return false;
                  }
                 
                });
              } else {
                post.setEntity(new InputStreamEntity(contentStream[0].getStream(), -1) {
                  @Override
                  public Header getContentType() {
                    return new BasicHeader("Content-Type", contentStream[0].getContentType());
                  }
                 
View Full Code Here

        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
        HttpResponse resp2 = HttpTestUtils.make500Response();
        byte[] body = HttpTestUtils.getRandomBytes(101);
        ByteArrayInputStream buf = new ByteArrayInputStream(body);
        ConsumableInputStream cis = new ConsumableInputStream(buf);
        HttpEntity entity = new InputStreamEntity(cis, 101);
        resp2.setEntity(entity);

        backendExpectsAnyRequest().andReturn(resp2);

        replayMocks();
View Full Code Here

    private HttpEntity makeStreamingEntity() {
        byte[] body = HttpTestUtils.getRandomBytes(101);
        ByteArrayInputStream buf = new ByteArrayInputStream(body);
        cis = new ConsumableInputStream(buf);
        return new InputStreamEntity(cis, 101);
    }
View Full Code Here

        setMinimalResponseHeaders(resp);
        resp.setHeader("Content-Length","" + nbytes);

        final Flag closed = new Flag();
        ByteArrayInputStream bais = makeTrackableBody(nbytes, closed);
        resp.setEntity(new InputStreamEntity(bais, -1));
       
        impl.ensureProtocolCompliance(req, resp);
        assertNull(resp.getEntity());
        assertTrue(closed.set || bais.read() == -1);
    }
View Full Code Here

        int nbytes = 128;
        HttpResponse resp = makePartialResponse(nbytes);
       
        final Flag closed = new Flag();
        ByteArrayInputStream bais = makeTrackableBody(nbytes, closed);
        resp.setEntity(new InputStreamEntity(bais, -1));
       
        try {
            impl.ensureProtocolCompliance(req, resp);
        } catch (ClientProtocolException expected) {
        }
View Full Code Here

        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));
       
        try {
            impl.ensureProtocolCompliance(req, resp);
        } catch (ClientProtocolException expected) {
        }
View Full Code Here

TOP

Related Classes of org.apache.http.entity.InputStreamEntity

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.