What I am doing:
Trying to get familiar with the HTTP protocol and it’s implementation.
My question:
Is it possible to get the headers (specifically Content-Length) of an HTTP GET before you read the actual body? From what I understand, I could use a HEAD call for that purpose, but am trying to see if it is even required. Specifically, in the HttpClient commons library (and most other I guess), there are methods to retrieve the response body as a stream. Is this stream being read from the socket as it’s coming in or has it already been buffered?
Thanks!
If the content-length header field is sent in the response header, you can read it before the response body. But sometimes (dynamically generatted content, unbuffered) it can be omitted (rfc). This is what happens when your browser can’t display a progress bar while downloading.