Package org.apache.http.entity

Examples of org.apache.http.entity.BasicHttpEntity


    }
   
    public void testResponseContentEntityContentLenghtDelimited() throws Exception {
        HttpContext context = new HttpExecutionContext(null);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        BasicHttpEntity entity = new BasicHttpEntity();
        entity.setContentLength (10);
        response.setEntity(entity);
        ResponseContent interceptor = new ResponseContent();
        interceptor.process(response, context);
        Header h1 = response.getFirstHeader(HTTP.CONTENT_LEN);
        assertNotNull(h1);
View Full Code Here


    }
   
    public void testResponseContentEntityUnknownContentLength() throws Exception {
        HttpContext context = new HttpExecutionContext(null);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        BasicHttpEntity entity = new BasicHttpEntity();
        response.setEntity(entity);
        ResponseContent interceptor = new ResponseContent();
        interceptor.process(response, context);
        Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
        assertNull(h1);
View Full Code Here

    }
   
    public void testResponseContentEntityChunkedHTTP10() throws Exception {
        HttpContext context = new HttpExecutionContext(null);
        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
        BasicHttpEntity entity = new BasicHttpEntity();
        entity.setChunked(true);
        response.setEntity(entity);
        ResponseContent interceptor = new ResponseContent();
        interceptor.process(response, context);
        Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
        assertNull(h1);
View Full Code Here

    }

    public void testResponseContentEntityNoContentTypeAndEncoding() throws Exception {
        HttpContext context = new HttpExecutionContext(null);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        BasicHttpEntity entity = new BasicHttpEntity();
        response.setEntity(entity);
        ResponseContent interceptor = new ResponseContent();
        interceptor.process(response, context);
        Header h1 = response.getFirstHeader(HTTP.CONTENT_TYPE);
        assertNull(h1);
View Full Code Here

    }
       
    public void testResponseContentEntityContentTypeAndEncoding() throws Exception {
        HttpContext context = new HttpExecutionContext(null);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        BasicHttpEntity entity = new BasicHttpEntity();
        entity.setContentEncoding("whatever");
        entity.setContentType("whatever");
        response.setEntity(entity);
        ResponseContent interceptor = new ResponseContent();
        interceptor.process(response, context);
        Header h1 = response.getFirstHeader(HTTP.CONTENT_TYPE);
        assertNotNull(h1);
View Full Code Here

   
    public void testSetResponseEntity() {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        assertNull(response.getEntity());
       
        HttpEntity entity = new BasicHttpEntity();
        response.setEntity(entity);
        assertTrue(entity == response.getEntity());
    }
View Full Code Here

   
    public void testSetRequestEntity() {
        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("GET", "/");
        assertNull(request.getEntity());
       
        HttpEntity entity = new BasicHttpEntity();
        request.setEntity(entity);
        assertTrue(entity == request.getEntity());
    }
View Full Code Here

        state.setRequest(request);
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
                HttpStatus.SC_NOT_MODIFIED, "Not modified");
        response.setEntity(new BasicHttpEntity());
        Mockito.when(this.conn.getHttpResponse()).thenReturn(response);

        this.protocolHandler.responseReceived(this.conn);

        Assert.assertEquals(MessageState.READY, state.getResponseState());
View Full Code Here

            public void handle(
                    final HttpRequest request,
                    final HttpResponse response,
                    final HttpContext context) throws HttpException, IOException {
                BasicHttpEntity entity = new BasicHttpEntity() {

                    @Override
                    public void writeTo(
                            final OutputStream outstream) throws IOException {
                        byte[] tmp = new byte[5];
                        outstream.write(tmp);
                        outstream.flush();
                       
                        // do something comletely ugly in order to trigger
                        // MalformedChunkCodingException
                        DefaultHttpServerConnection conn = (DefaultHttpServerConnection)
                            context.getAttribute(ExecutionContext.HTTP_CONNECTION);
                        try {
                            conn.sendResponseHeader(response);
                        } catch (HttpException ignore) {
                        }
                    }
                   
                } ;
                entity.setChunked(true);
                response.setEntity(entity);
            }
           
        });
       
View Full Code Here

            public void handle(
                    final HttpRequest request,
                    final HttpResponse response,
                    final HttpContext context) throws HttpException, IOException {
                BasicHttpEntity entity = new BasicHttpEntity() {

                    @Override
                    public void writeTo(
                            final OutputStream outstream) throws IOException {
                        byte[] tmp = new byte[5];
                        outstream.write(tmp);
                        outstream.flush();

                        // do something comletely ugly in order to trigger
                        // MalformedChunkCodingException
                        DefaultHttpServerConnection conn = (DefaultHttpServerConnection)
                            context.getAttribute(ExecutionContext.HTTP_CONNECTION);
                        try {
                            conn.sendResponseHeader(response);
                        } catch (HttpException ignore) {
                        }
                    }

                } ;
                entity.setChunked(true);
                response.setEntity(entity);
            }

        });
View Full Code Here

TOP

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

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.