Search code examples
httprequestresponse

HTTP request/response flow


I'm trying to dissect a single HTTP request made to some website --> www.somesite.com ... If I understand correctly, the browser will issue a GET request as such:

GET http://www.somesite.com/index.html HTTP/1.1

Ultimately the server will send a response as such:

HTTP/1.1 200 OK

Date: Fri, 21 Feb 2014 10:00:00 GMT

Content-Type: text/html

Content-Length: 1354

<html>
<body>
.
.
.
</body>
</html>

Assuming this index.html contains images and css and javascript assets, if the response was simply 200 OK, how does the client know to go back and fetch the other assets? Meaning, how does the client know that index.html has been served in its entirety when all it did was simply issue the first GET request?


Solution

  • Well, it is hard to understand, what you want to know. The first get will either return data or redirect elsewhere. When browser receives HTML page, it will parse it to element tree and saves links to download (css, js, images). It downloads them and if they contain references to other resources (js, css, images), it will download them as well. When the queue is empty, browser finishes downloading.

    Does this high level description answear your question?