2016/01/21

HttpResponse Stream


あまり情報がないので、
 
★The respone entity is always not null and is stream,so the 
  releaseConnection method cant be invoked always.
  
  
   final HttpEntity entity = response.getEntity(); 
  if (entity == null || !entity.isStreaming()) { 
 
★ 

  1. Using EntityUtils and HttpEntity
    HttpResponse response = httpClient.execute(new HttpGet(URL));
    HttpEntity entity = response.getEntity();
    String responseString = EntityUtils.toString(entity, "UTF-8");
    System.out.println(responseString);
  2. Using BasicResponseHandler
    HttpResponse response = httpClient.execute(new HttpGet(URL));
    String responseString = new BasicResponseHandler().handleResponse(response);
    System.out.println(responseString);
     
     
    基本なことね、恥ずかしい、全てのresponeはStreamみたいなので
    、また調べる