How does the communication between a browser and a web server take place?

后端 未结 8 1738
梦谈多话
梦谈多话 2020-12-12 10:51

Can anyone explain how the communication takes place between the browser and web server? I want to learn how

  • GET, POST verbs (among others)
  • cookies
8条回答
  •  悲哀的现实
    2020-12-12 11:31

    Your browser first resolves the servername via DNS to an IP. Then it opens a TCP connection to the webserver and tries to communicate via HTTP. Usually that is on TCP-port 80 but you can specify a different one (http://server:portnumber).

    HTTP looks like this:

    Once it is connected, it sends the request, which looks like:

    GET /site HTTP/1.0
    Header1: bla
    Header2: blub
    {emptyline}
    

    E.g., a header might be Authorization or Range. See here for more.

    Then the server responds like this:

    200 OK
    Header3: foo
    Header4: bar
    
    content following here...
    

    E.g., a header might be Date or Content-Type. See here for more.

    Look at Wikipedia for HTTP for some more information about this protocol.

提交回复
热议问题