HTTP knowledge Pits

Source: Internet
Author: User
Tags ack

What did the browser and computer do when we entered the URL to enter or refresh the page?

The first is the domain name resolution , 1. The browser first searches its own DNS cache

2. If the browser does not find the cache or the cache is invalidated, the computer searches its own DNS cache

3. Read the local Host file

4. Browser initiates a system call to a DNS

Broadband carrier Server View itself cache

The carrier server initiates a request for an iterative DNS resolution

The carrier server caches the results back to the operating system kernel.

The operating system kernel returns the results to the browser

The browser gets the www.xxxxxx.com IP address.

5. After the browser obtains the IP address of the domain name, it initiates the HTTP classic "three-time handshake"

Once the 6.TCP/IP link is set up, the browser can make an HTTP request to the server

7. The server side received this request, according to the path parameter, after some processing of the backend, the processed result data is returned to the browser, such as the full HTML code of the page back to the browser

8. After the browser has got the full HTML code, in parsing and rendering this page, inside js,css, picture static resources, they are also a HTTP request, have to go through the above seven steps

9. The browser renders the page based on the resources it has received, eventually presenting a complete page to the user

The explanation for the three-time handshake is this:

TCP is the host-to-host layer of the Transmission Control Protocol, providing a reliable connection service, using three-time handshake confirmation to establish a connection:

The bit code is the TCP flag bit, and there are 6 types of markings:

SYN (synchronous set up online)

ACK (Acknowledgement confirmation)

PSH (push transfer)

FIN (end of finish)

RST (Reset reset)

URG (Urgent emergency)

Sequence number (sequential numbers)

Acknowledge Number (confirmation)

Client TCP State Migration:
Closed->syn_sent->established->fin_wait_1->fin_wait_2->time_wait->closed
Server TCP State Migration:
Closed->listen->syn received->established->close_wait->last_ack->closed

The meanings of each state are as follows:
LISTEN-listens for connection requests from remote TCP ports;
Syn-sent-waits for a matching connection request after the connection request is sent;
Syn-received-Waits for confirmation of the connection request after receiving and sending a connection request;
established-represents an open connection, the data can be transmitted to the user;
Fin-wait-1-a connection interruption request waiting for a remote TCP, or confirmation of a previous connection interruption request;
Fin-wait-2-Waits for a connection interrupt request from a remote TCP;
Close-wait-waits for a connection interruption request from a local user;
CLOSING-Wait for the remote TCP acknowledgement of the connection interruption;
Last-ack-Acknowledgement of the connection interrupt request that was originally sent to the remote TCP;
Time-wait-wait enough time to ensure that the remote TCP receives the acknowledgement of the connection interrupt request;
CLOSED-no connection status;

In the TCP/IP protocol, the TCP protocol provides a reliable connection service with a three-time handshake to establish a connection,

(1) First handshake: When a connection is established, client A sends a SYN packet (SYN=J) to Server B and enters the syn_send state, waiting for Server B to confirm.

(2) Second handshake: Server B receives the SYN packet, must confirm the SYN (ACK=J+1) of customer A, and also sends a SYN packet (syn=k), that is, the Syn+ack package, at which point Server B enters the SYN_RECV state.

(3) Third handshake: Client A receives Server B's Syn+ack package, sends acknowledgment packet ACK (ack=k+1) to Server B, the packet is sent, client A and Server B enter the established state, complete three handshake.

Three handshake is completed and the client and server begin to transfer data.

HTTP protocol can be rudely divided into requests and responses, requests and responses will send HTTP headers and body information. HTTP hair is sent with some additional information: the content type, the date the server sends the response, and the HTTP status code. The text is the form's data and the returned data.

HTTP knowledge Pits

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.