The HTTP communication mechanism is that during a complete HTTP communication, the following 7 steps will be completed between the Web browser and the Web server

Source: Internet
Author: User

1. Establish a TCP connection before HTTP work begins, the Web browser first establishes a connection to the Web server over the network, which is done through TCP, which works with the IP protocol to build the Internet, known as the TCP/IP protocol family, So the internet is also known as a TCP/IP network. HTTP is a higher level of application-level protocol than TCP, according to the rules, only the lower layer protocol is established before a higher-level protocol connection, therefore, the first to establish a TCP connection, the port number of the general TCP connection is 80.

2. Web browser sends a request command to the Web server once a TCP connection is established, the Web browser sends a request command to the Web server. For example: get/sample/hello.jsp http/1.1.

3. After the Web browser sends the request header information The browser sends its request command, it also sends some other information in the form of header information to the Web server, and then the browser sends a blank line to notify the server that it has ended sending the header information.

4. After the Web server answers the client to make a request to the server, the server sends back a reply, http/1.1, the first part of the answer is the version number of the protocol and the response status code.

5. The Web server sends the reply header information as the client sends information about itself along with the request, the server also sends the user with the answer about its own data and the requested document.

6. When the Web server sends a data Web server to the browser sends a header message to the browser, it sends a blank line to indicate that the header information is sent to the end, and then it sends the actual data requested by the user in the format described in the Content-type reply header information.

7. The Web server shuts down the TCP connection in general, once the Web server sends the request data to the browser, it closes the TCP connection and then if the browser or server joins this line of code in its header information: connection:keep-alive

The TCP connection remains open after it is sent, so the browser can continue to send requests through the same connection. Maintaining a connection saves the time it takes to establish a new connection for each request and also saves network bandwidth.

The HTTP communication mechanism is that during a complete HTTP communication, the following 7 steps will be completed between the Web browser and the Web server

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.