title: Receiving Content-Length:0 in header with Response code 200 for GET Response from Java client
body: <p>When I am trying to hit a <code>REST API URL</code> <strong>http:URL?param-name=param-value</strong>
  for downloading a <code>JSON</code> file from <code>Java</code> client, I am receiving the response body as empty with <code>Content-Length:0</code> in header and with status code as 200.</p>
  
  <p>I used <code>RestTemplate/HttpURLConnection/Apache HttpClient</code> to get the file content.. But no Luck</p>
  
  <p>However, file is downloadable from browser or any other <code>REST</code> client like <code>SOAP</code> or from command line like <code>wget</code> or <code>curl</code> (I guess because output mime type is automatically detected by all these tools).</p>
  
  <h1>Request and Response headers when request fired from Chrome ARC client</h1>
  
  <h2>Request</h2>
  
  <blockquote>
    <p>User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML,
    like Gecko)  Chrome/48.0.2564.116 Safari/537.36</p>
    
    <p>Content-Type: text/plain; charset=utf-8</p>
    
    <p>Accept: application/octet-stream</p>
    
    <p>Accept-Encoding: gzip, deflate, sdch</p>
    
    <p>Accept-Language: en-US,en;q=0.8</p>
    
    <p>Cookie:
    JSESSIONID=49LkWLLJMdNWhHRzh7FclGGSXvV2NKpbK0PYvCFp3vGFc2mwfpGh!-1680860256</p>
  </blockquote>
  
  <h2>Response</h2>
  
  <blockquote>
    <p>Cache-Control: no-cache, no-store, max-age=0, must-revalidate</p>
    
    <p>Date: Wed, 24 Feb 2016 05:05:20 GMT</p>
    
    <p>Pragma: no-cache</p>
    
    <p>Content-Length: 342950</p>
    
    <p>Content-Type: application/octet-stream</p>
    
    <p>Expires: 0</p>
    
    <p>Content-Disposition: attachment; filename=DevicePrices.json</p>
    
    <p>X-XSS-Protection: 1; mode=block</p>
    
    <p>X-Content-Type-Options: nosniff</p>
    
    <p>X-Powered-By: Servlet/3.0 JSP/2.2</p>
    
    <p>X-Frame-Options: DENY</p>
  </blockquote>
  
  <h1>Request and Response from java client</h1>
  
  <h2>Request Headers</h2>
  
  <blockquote>
    <p>Header-->Accept-charset-->UTF-8 </p>
    
    <p>Header-->Accept-->application/octet-stream</p>
    
    <p>Header-->Accept-Encoding-->gzip,deflate,sdch</p>
    
    <p>Header-->Content-Type-->text/plain;charset=utf-8</p>
    
    <p>Header-->Accept-Language-->en-US,en;q=0.8</p>
  </blockquote>
  
  <h2>Response Headers</h2>
  
  <blockquote>
    <p>Header-->Cache-Control-->no-cache, no-store, max-age=0,
    must-revalidate</p>
    
    <p>Header-->Date-->Wed, 24 Feb 2016 04:32:39 GMT</p>
    
    <p>Header-->Pragma-->no-cache</p>
    
    <p>Header-->Content-Length-->0</p>
    
    <p>Header-->Content-Type-->application/octet-stream</p>
    
    <p>Header-->Expires-->0</p>
    
    <p>Header-->Content-Disposition-->attachment; filename=DevicePrices.json</p>
    
    <p>Header-->X-XSS-Protection-->1; mode=block</p>
    
    <p>Header-->X-Content-Type-Options-->nosniff</p>
    
    <p>Header-->X-Powered-By-->Servlet/3.0 JSP/2.2</p>
    
    <p>Header-->X-Frame-Options-->DENY</p>
  </blockquote>
  
  <p>I tried to mock the request headers but still the same issue that no content body received. I am stuck with this since long. </p>
  
  <p>What might be the reasons for this behavior? 
  Please suggest me the ways to retrieve the file content.</p>
  
  <p>Adding the code snippet using Apache HttpClient:</p>
  
  <pre><code>DefaultHttpClient httpclient = new DefaultHttpClient();
  HttpGet get=new HttpGet(url);
  get.setHeader("Accept-charset", "UTF-8");
  get.setHeader("Content-Type", "text/plain; charset=utf-8");
  get.setHeader("Accept","*/*");
  get.setHeader("Accept-Encoding","gzip,deflate,sdch");
  get.setHeader("Content-Type","text/plain;charset=utf-8");
  get.setHeader("Accept-Language", "en-US,en;q=0.8");
  HttpResponse resp=client.execute(get);
  System.out.println(EntityUtils.toString(resp.getEntity()));
  </code></pre>
  
  <p>If I use get.setHeader("Accept","application/json"), server responding in 406-Non Acceptable error.</p>