Java 类org.apache.http.conn.EofSensorInputStream 实例源码

项目:pico    文件:BitmapJsonRestHandler.java   
@Override
protected void storeResponse(HttpResponse response, ICommRestResponse restResponse) throws Exception{
    try{
        // deconstruct the response entity      
        HttpEntity entity = response.getEntity();        
        // debug
        System.out.println(entity.getContentType());
        System.out.println(entity.getContentLength());
        LogHelper.w("RestRequest-Response", "content length %d", entity.getContentLength());
        System.out.println(EntityUtils.getContentCharSet(entity));
        // get input stream
        org.apache.http.conn.EofSensorInputStream inputStream = (EofSensorInputStream) entity.getContent();
        // get image from input stream
        Bitmap image = BitmapFactory.decodeStream(inputStream);
        // add to response
        ICommRestResponse<Bitmap> streamResponse = restResponse;
        streamResponse.setResponseContent(image);
        // set success
        restResponse.setResponseCode( (long) (image == null ? 999 : 0));
    }catch(Exception ex){
        restResponse.setErrorMessage(ex.getMessage());
        restResponse.setResponseCode((long) 999);
    }
}
项目:pico    文件:BitmapJsonRestHandler.java   
@Override
protected void storeResponse(HttpResponse response, ICommRestResponse restResponse) throws Exception{
    try{
        // deconstruct the response entity      
        HttpEntity entity = response.getEntity();        
        // debug
        System.out.println(entity.getContentType());
        System.out.println(entity.getContentLength());
        LogHelper.w("RestRequest-Response", "content length %d", entity.getContentLength());
        System.out.println(EntityUtils.getContentCharSet(entity));
        // get input stream
        org.apache.http.conn.EofSensorInputStream inputStream = (EofSensorInputStream) entity.getContent();
        // get image from input stream
        Bitmap image = BitmapFactory.decodeStream(inputStream);
        // add to response
        ICommRestResponse<Bitmap> streamResponse = restResponse;
        streamResponse.setResponseContent(image);
        // set success
        restResponse.setResponseCode( (long) (image == null ? 999 : 0));
    }catch(Exception ex){
        restResponse.setErrorMessage(ex.getMessage());
        restResponse.setResponseCode((long) 999);
    }
}
项目:riptide    文件:RestAsyncClientHttpResponseBodyTest.java   
@Test
public void shouldCallAbortAndCloseOnConnectionReleaseTrigger() throws IOException {
    EofSensorInputStream stream = mock(EofSensorInputStream.class);
    ClientHttpResponse response = mock(ClientHttpResponse.class);
    when(response.getBody()).thenReturn(stream);

    try (RestAsyncClientHttpResponse unit = new RestAsyncClientHttpResponse(response)) {
        unit.getBody().close();
    }

    verify(stream).abortConnection();
    verify(stream).close();
}
项目:pico    文件:StreamingJsonRestHandler.java   
@Override
protected void storeResponse(HttpResponse response, ICommRestResponse restResponse) throws Exception{
    // deconstruct the response entity

       HttpEntity entity = response.getEntity();        
       // debug
       System.out.println(entity.getContentType());
       System.out.println(entity.getContentLength());
       System.out.println(EntityUtils.getContentCharSet(entity));
       // get input stream
       org.apache.http.conn.EofSensorInputStream inputStream = (EofSensorInputStream) entity.getContent();      
    // add to response
    ICommRestResponse<InputStream> streamResponse = restResponse;
    streamResponse.setResponseContent(inputStream);
}
项目:pico    文件:StreamingJsonRestHandler.java   
@Override
protected void storeResponse(HttpResponse response, ICommRestResponse restResponse) throws Exception{
    // deconstruct the response entity

       HttpEntity entity = response.getEntity();        
       // debug
       System.out.println(entity.getContentType());
       System.out.println(entity.getContentLength());
       System.out.println(EntityUtils.getContentCharSet(entity));
       // get input stream
       org.apache.http.conn.EofSensorInputStream inputStream = (EofSensorInputStream) entity.getContent();      
    // add to response
    ICommRestResponse<InputStream> streamResponse = restResponse;
    streamResponse.setResponseContent(inputStream);
}
项目:purecloud-iot    文件:ResponseEntityProxy.java   
@Override
public InputStream getContent() throws IOException {
    return new EofSensorInputStream(this.wrappedEntity.getContent(), this);
}