0

I have some knowledge on my question but not exactly. What exactly programatically happening after http request?

Scott Hanselman said in one of his blog posts:

Describe, in as much detail as you think is relevant, as deeply as you can, what happens when I type "cnn.com" into a browser and press "Go".

My question is exactly this,

0

2 Answers 2

10

That's like asking "describe how to perform a coronary bypass". Yes, one can explain how, but one is better first studying medicine and learning about the basics, before starting with specific procedures. However, in bulletpoints:

  1. Your browser will want to know the IP address of cnn.com. It doesn't do DNS lookups itself, but rather asks the operating system.
  2. Your browser will connect to that IP address on port 80
  3. Your browser will send a HTTP GET request
  4. The webserver will reply with statuscode 200 and the body contents
  5. Your browser will parse the HTML
  6. In the HTML, other resources (images, scripts, css-files...) might be included, which the browser will also fetch.
  7. After the browser is done, it will close the connection. If it doesn't, the webserver will.
Sign up to request clarification or add additional context in comments.

6 Comments

Decent answer. Will give +1 once you add books he should read
Sorry, I don't believe in books to read about internet. I'm willing to link to RFCs, Open University presentations - but I'm guessing since he is asking a rather vague entry-level question, wikipedia will be a good start. No need to start talking about TCP and OSI yet, imho.
thanks for the answer. I agree with you about the complexity of the process.
how does the web browser resolve the ip address with domain name?
@tugberk: it asks the operating system. You can do this yourself: open a command prompt, and type nslookup cnn.com. nslookup will contact your name server (see which one in ipconfig /all) and will ask the name server if it knows the IP-address. The name server will either know, or go ask someone else until it knows. It then replies to your computer.
|
2

Browser tries to resolve the name cnn.com into its ip address.

Browser TCP connects to cnn.com's ip address on the default HTTP port (80)

Browser sends a GET request to the server, asking for the / page

Browser says that it's trying to connect to "cnn.com" (cnn.com and bbc.com could be hosted on the same hosting company, with the same IP address)

Browser also says what's your browser, browser engine, browser version, operating system and the plug-ins that you have installed.

Server sends a header saying what's coming on your reply, the kind of data you're going to receive (in this case, HTML), and the size of the response if it's available.

Server closes the connection if there isn't any keep-alive instruction from the browser. Otherwise it will use this opened connection to ask for other things that might be needed (images within the page, for example.)

By the way, download and install Wireshark if you want to go deep and see what's really going on behind the curtains.

4 Comments

the wireshark is like fiddler?
+1 For the wireshark suggestion - a good start to reverse engineer network protocols.
@tugberk: Yes, wireshark is like fiddler, but a bit more broad: it captures ANY outgoing traffic (so it also includes when you talk on MSN or fetch e-mail).
wireshark is awesome to learn more about protocols. have fun playing with it ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.