Package org.apache.http

Examples of org.apache.http.HttpEntity.writeTo()


     */
  public void writeTo(final OutputStream outputStream) throws IOException {
        if (this.httpResponse != null && this.currentRequest != null) {
            final HttpEntity httpEntity = this.httpResponse.getEntity();
            if (httpEntity != null) try {
                httpEntity.writeTo(outputStream);
                outputStream.flush();
                // Ensures that the entity content is fully consumed and the content stream, if exists, is closed.
                EntityUtils.consume(httpEntity);
                ConnectionInfo.removeConnection(this.currentRequest.hashCode());
                this.currentRequest = null;
View Full Code Here


        }
       
        HttpEntity e = response.getEntity();
        assertNotNull(e);
        ByteArrayOutputStream outsteam = new ByteArrayOutputStream();
        e.writeTo(outsteam);
       
        // Expect one connection in the pool
        assertEquals(1, mgr.getConnectionsInPool());

        // Make sure one connection is available
View Full Code Here

                        }

                        HttpEntity entity = request.getEntity();
                        OutputStream outstream = new ContentOutputStream(
                                connState.getOutbuffer());
                        entity.writeTo(outstream);
                        outstream.flush();
                        outstream.close();

                        synchronized (connState) {
                            connState.setWorkerRunning(false);
View Full Code Here

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        try {
            response = httpClient.execute(request);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                entity.writeTo(outputStream);
            }
            responseBody = outputStream.toString("UTF-8");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

      if (entity != null)
      {
         OutputStream servletOutputStream = servletResponse.getOutputStream();
         try
         {
            entity.writeTo(servletOutputStream);
         }
         finally
         {
            closeQuietly(servletOutputStream);
         }
View Full Code Here

            }
         
        });
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        httpentity.writeTo(out);
        byte[] bytes2 = out.toByteArray();
        assertNotNull(bytes2);
        assertEquals(1, bytes2.length);
       
        try {
View Full Code Here

        byte[] bytes2 = out.toByteArray();
        assertNotNull(bytes2);
        assertEquals(1, bytes2.length);
       
        try {
            httpentity.writeTo(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

            final HttpEntityEnclosingRequest request,
            final ClientConnState connState) throws IOException {
        HttpEntity entity = request.getEntity();
        if (entity != null) {
            OutputStream outstream = new ContentOutputStream(connState.getOutbuffer());
            entity.writeTo(outstream);
            outstream.flush();
            outstream.close();
        }
    }
   
View Full Code Here

        if (response.getEntity() != null) {
            ContentOutputBuffer buffer = connState.getOutbuffer();
            OutputStream outstream = new ContentOutputStream(buffer);

            HttpEntity entity = response.getEntity();
            entity.writeTo(outstream);
            outstream.flush();
            outstream.close();
        }
       
        synchronized (connState) {
View Full Code Here

                        }
                       
                        HttpEntity entity = request.getEntity();
                        OutputStream outstream = new ContentOutputStream(
                                connState.getOutbuffer());
                        entity.writeTo(outstream);
                        outstream.flush();
                        outstream.close();

                        synchronized (connState) {
                            connState.setWorkerRunning(false);
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.