Package org.apache.http

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


            // If the request entity is repeatable, we can send it first to
            // our own stream, so we can return it
            final HttpEntity entityEntry = entity.getEntity();
            if(entityEntry.isRepeatable()) {
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                entityEntry.writeTo(bos);
                bos.flush();
                // We get the posted bytes using the charset that was used to create them
                entityBody.append(new String(bos.toByteArray(), charset));
                bos.close();
            }
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();
            terminalState = ServerConnState.RESPONSE_BODY_DONE;
        } else {
            ioControl.requestOutput();
View Full Code Here

       
        if (response.getEntity() != null) {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                OutputStream outstream = new ContentOutputStream(buffer);
                entity.writeTo(outstream);
                outstream.flush();
                outstream.close();
            }
        } else {
            connState.resetOutput();
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

        connState.setOutputState(ServerConnState.RESPONSE_SENT);

        HttpEntity entity = response.getEntity();
        if (entity != null) {
            OutputStream outstream = new ContentOutputStream(buffer);
            entity.writeTo(outstream);
            outstream.flush();
            outstream.close();
        } else {
            connState.resetOutput();
            if (!this.connStrategy.keepAlive(response, context)) {
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

                        }
                       
                        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

        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

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.