I'm trying to figure out how this works exactly.
HttpWebRequest
has a method BeginGetResponse
which accepts as a parameter a ResponseCallback
. Firstly, is this callback called immediately (in a new thread) or once it receives a response back from the server? Or is it the job of EndGetResponse
to wait for the response?
Secondly, once you have the response, you can access the response stream immediately, but the stream doesn't contain the full page until it's completed downloading, hence BeginRead
. However, I seem to be able to access all the headers immediately, through properties like HttpWebResponse.ContentLength
. Does this mean that EndGetResponse
doesn't complete until the headers are fully downloaded, or is it that when you call the ContentLength
parameter it hangs for a bit until that header is received?