title: HttpClient: Determine empty entity in response
body: <p>I'm wondering how to determine an empty http response.
  With empty http response I mean, that the http response will only have set some headers, but contains an empty http body.</p>
  
  <p>For example: I do a HTTP POST to an webserver, but the webserver will only return an status code for my HTTP POST and nothing else.</p>
  
  <p>The problem is, that I have written a little http framework on top of apache HttpClient to do auto json parsing etc. So the default use case of this framework is to make a request and parse the response. However if the response does not contain data, like mentioned in the example above, I will ensure that my framework skip json parsing.</p>
  
  <p>So I do something like this:</p>
  
  <pre><code>HttpResponse response = httpClient.execute(uriRequest);
  HttpEntity entity = response.getEntity();
  if (entity != null){
      InputStream in = entity.getContent();
      // json parsing
  }
  </code></pre>
  
  <p>However entity is always != null. And also the retrieved inputstream is != null. Is there a simple way to determine if the http body is empty or not?</p>
  
  <p>The only way I see is that the server response contains the Content-Length header field set to 0.
  But not every server set this field.</p>
  
  <p>Any suggestions?</p>