title: Apache HttpClient response content length returns -1
body: <p>Why does the following Code returns -1? Seems that the request failed.</p>
  
  <pre><code>public static void main(String[] args)
  {
      DefaultHttpClient httpClient = new DefaultHttpClient();
      HttpGet httpGet = new HttpGet("http://www.google.de");
  
      HttpResponse response;
      try
      {
          response = httpClient.execute(httpGet);
          HttpEntity entity = response.getEntity();
          EntityUtils.consume(entity);
  
          // Prints -1
          System.out.println(entity.getContentLength());
      }
      catch (ClientProtocolException e)
      {
          e.printStackTrace();
      }
      catch (IOException e)
      {
          e.printStackTrace();
      }
      finally
      {
          httpGet.releaseConnection();
      }
  }
  </code></pre>
  
  <p>And is it possible to get the response as String?</p>