title: Java Apache HTTP Client fails with http request where cURL succeed
body: <p>I'm finding difficult performing a simple http request in Java using apache http client. The request is a simple GET toward the following url <a href="http://109.231.121.64:20622/v1/collections/S4C/objects/OpsConfig/data" rel="nofollow">http://109.231.121.64:20622/v1/collections/S4C/objects/OpsConfig/data</a> (which is currently up and running). The request succeed using curl like in the following: </p>
  
  <pre><code>curl -v -X GET http://109.231.121.64:20622/v1/collections/S4C/objects/OpsConfig/data &gt; s4cOpsInitModel.xml    
  </code></pre>
  
  <p>And this is the output:</p>
  
  <pre><code>* Hostname was NOT found in DNS cache    
  *   Trying 109.231.121.64...    
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current    
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:----:--:--     0* Connected to 109.231.121.64 (109.231.121.64) port 20622 (#0)
  &gt; GET /v1/collections/S4C/objects/OpsConfig/data HTTP/1.1
  &gt; User-Agent: curl/7.35.0
  &gt; Host: 109.231.121.64:20622
  &gt; Accept: */*
  &gt; 
  &lt; HTTP/1.1 200 OK
  &lt; connection: keep-alive
  * Server Cowboy is not blacklisted
  &lt; server: Cowboy
  &lt; date: Tue, 08 Sep 2015 08:11:22 GMT
  &lt; content-length: 2349
  &lt; content-type: application/octet-stream
  &lt; 
  { [data not shown]
  100  2349  100  2349    0     0  27819      0 --:--:-- --:--:----:--:-- 27964
  * Connection #0 to host 109.231.121.64 left intact
  </code></pre>
  
  <p>but then when doing the same in Java an http error status 500 s returned. Here is the code I'm using:</p>
  
  <pre><code>try {
  
  
          DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpGet getRequest = new HttpGet(
              "http://109.231.121.64:20622/v1/collections/S4C/objects/OpsConfig/data");
  
  
          HttpResponse response = httpClient.execute(getRequest);
  
          if (response.getStatusLine().getStatusCode() != 200) {
              throw new RuntimeException("Failed : HTTP error code : "
                 + response.getStatusLine().getStatusCode());
          }
  
          BufferedReader br = new BufferedReader(
                           new InputStreamReader((response.getEntity().getContent())));
  
          String output;
          System.out.println("Output from Server .... \n");
          while ((output = br.readLine()) != null) {
              System.out.println(output);
          }
  
          httpClient.getConnectionManager().shutdown();
  
        } catch (ClientProtocolException e) {
  
          e.printStackTrace();
  
        } catch (IOException e) {
  
          e.printStackTrace();
  }    
  </code></pre>
  
  <p>I had a look on google but I cannot figured out what's happening. My guess is that something is wrong with the accepted content type, but I tried to set different kind of content type without succeeding. Do you have any idea about what I'm doing wrong? Thank you all in advance.</p>