Home  >  Article  >  What is http life cycle

What is http life cycle

青灯夜游
青灯夜游Original
2019-05-09 15:31:245787browse

The http life cycle is: 1. The HTTP client establishes a TCP socket connection with the HTTP port of the Web server; 2. Through the TCP socket, the client sends a text request message to the Web server ; 3. The server parses the request and returns an HTTP response; 4. Releases the TCP connection; 5. The client browser parses the HTML content.

What is http life cycle

#What is the http life cycle? The following article will introduce you to the http request life cycle process. I hope it will be helpful to you.

http life cycle

1. Client connects to the Web server

An HTTP client, usually a browser, interacts with the Web Establish a TCP socket connection to the server's HTTP port (80 by default).

2. Send HTTP request

Through the TCP socket, the client sends a text request message to the Web server. A request message consists of a request line, a request header, and a blank line. It consists of 4 parts and request data.

3. The server parses the request and returns an HTTP response.

The Web server parses the request and locates the requested resource. The server writes a copy of the resource to the TCP socket, which is read by the client. A response consists of four parts: status line, response header, blank line and response data.

4. Release the connection TCP connection

If the connection mode is close, the server actively closes the TCP connection, and the client passively closes the connection and releases the TCP connection; if the connection mode is keepalive, the connection It will be maintained for a period of time during which requests can continue to be received.

5. The client browser parses the HTML content

The client browser first parses the status line to check the status code indicating whether the request was successful. Then each response header is parsed, and the response header tells the following HTML document of several bytes and the character set of the document. The client browser reads the response data HTML, formats it according to the syntax of HTML, and displays it in the browser window.

The above is the detailed content of What is http life cycle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn