Why is the Content-Length header omitted from server response when using HttpClient?
<p>I am using this question's source code <a href="http://stackoverflow.com/questions/9594318/how-to-asynchronous-perform-a-httprequest-and-show-the-progress-of-downloading-t">How to asynchronous perform a httprequest and show the progress of downloading the response</a>  in order to fetch a webpage's html source and display a progressbar with the downloaded data so far and how much the total size of the page is.</p>

<p>That particular code doesn't actually work on ICS 4.0.3 because clHeaders[0] doesn't point to anything and an exception is raised called ArrayIndexOutOfBounds at index 0 because the Content-Length header is omitted from the server's response. I tried using getContentLength in case that was the problem - it returned a negative value of  -1 then I iterated over all the headers and the Content-Length was not there. After removing those bits, the code works fine and a webpage is fetched, written to a file and the size as it is being downloaded is displayed but obviously not the end size till I actually download it all.</p>

<p>I only have three ideas of the cause:
1.)I am not sending a Content-Length header thus I am not receiving one either - but this sounds wrong. Plus I have no idea if the HttpClient isn't sending one in the background.
2.)I read here in another question that if the response of the server was streaming or chunked then getContentLength can return -1.
3.)Gzip? But I have no idea how to disable it or if it was enabled in the first place</p>

<p>If you are thinking it's the server that is broken, I tried many websites including Google and still no Content-Length header whatsoever.</p>
