Package org.apache.http

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


        if (resEntity != null) {
            System.out.println("Response content length: " + resEntity.getContentLength());
            System.out.println("Chunked?: " + resEntity.isChunked());
        }
        if (resEntity != null) {
            resEntity.consumeContent();
        }
    }
   
}
View Full Code Here


            public void writeTo(final OutputStream outstream) throws IOException {
                outstream.write('a');
            }
         
        });
        httpentity.consumeContent(); // Has no effect
        try {
            httpentity.getContent();
            fail("UnsupportedOperationException should have been thrown");
        } catch (UnsupportedOperationException ex) {
            // expected
View Full Code Here

            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                //success
                try {
                    entity = response.getEntity();
                    String entityResponse = EntityUtils.toString(entity);
                    entity.consumeContent();
                    if (!db.equals(JSONDataBinding.NAME)) {
                        JSONObject jsonResponse = new JSONObject(entityResponse);

                        if (!jsonResponse.has("result")) {
                            processException(jsonResponse);
View Full Code Here

                HttpResponse response = this.client.execute(post, host, conn);

                HttpEntity entity = response.getEntity();
                assertNotNull(entity);
                entity.consumeContent();
               
                if (r < 2) {
                    assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getStatusLine().getStatusCode());
                } else {
                    assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
View Full Code Here

                } else {
                    if (reuse) {
                        // Make sure the response body is fully consumed, if present
                        HttpEntity entity = response.getEntity();
                        if (entity != null) {
                            entity.consumeContent();
                        }
                        // entity consumed above is not an auto-release entity,
                        // need to mark the connection re-usable explicitly
                        managedConn.markReusable();
                    } else {
View Full Code Here

                        if (this.reuseStrategy.keepAlive(response, context)) {
                            this.log.debug("Connection kept alive");
                            // Consume response content
                            HttpEntity entity = response.getEntity();
                            if (entity != null) {
                                entity.consumeContent();
                            }               
                        } else {
                            this.managedConn.close();
                        }
                       
View Full Code Here

            result = responseHandler.handleResponse(response);
        } catch (Throwable t) {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (Throwable t2) {
                    // Log this exception. The original exception is more
                    // important and will be thrown to the caller.
                    this.log.warn("Error consuming content after an exception.", t2);
                }
View Full Code Here

        // Handling the response was successful. Ensure that the content has
        // been fully consumed.
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            // Let this exception go to the caller.
            entity.consumeContent();
        }

        return result;
    }
View Full Code Here

        HttpResponse response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();

        System.out.println("Login form get: " + response.getStatusLine());
        if (entity != null) {
            entity.consumeContent();
        }
        System.out.println("Initial set of cookies:");
        List<Cookie> cookies = httpclient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {
            System.out.println("None");
View Full Code Here

        response = httpclient.execute(httpost);
        entity = response.getEntity();

        System.out.println("Login form get: " + response.getStatusLine());
        if (entity != null) {
            entity.consumeContent();
        }

        System.out.println("Post logon cookies:");
        cookies = httpclient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {
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.