1. Introduction to HTTP Protocol
2. Main Features of HTTP
3. HTTP request structureHTTP request message consists of 3 parts (request line + request header + request body) HTTP request structure: 3.1 Request LineRequest line : It consists of three fields: request field, URL field, and HTTP protocol version field, which are separated by spaces. For example: GET/material/index HTTP/1.1\r\nAccording to the HTTP standard, HTTP requests can use multiple request methods. HTTP1.0 defines three request methods: GET, POST, and HEAD. HTTP1.1 adds five new request methods: OPTIONS, PUT, DELETE, TRACE, and CONNECT. 3.2 Request HeaderRequest header: HTTP client programs (such as browsers) must specify the request type (usually GET or POST) when sending requests to the server. If necessary, the client program can also choose to send other request headers. Most request headers are not required, but Content-Length is an exception. For POST requests, Content-Length must appear. The request header informs the server about the client's request. Typical request headers are: 3.3 Blank linesIts function is to tell the server that the request header information ends here. 3.4 Request Body
Examples:4. HTTP response structureHTTP response structure: HTTP response message consists of three parts: (status line, response header, response body) 4.1 Response LineResponse line: describes the status of the response, which is generally composed of the protocol version, status code and its description, such as HTTP/1.1200OK\r\n, where the protocol version is HTTP/1.1 or HTTP/1.0, 200 is its status code, and OK is its description. Five possible values: Common status codes: 4.2 Response HeaderResponse header: Used to describe the basic information of the server and the data. Through the description of this data, the server can inform the client how to process the data it sends back later. 4.3 Response BodyThe response body is the message body of the response, which contains the content of the response. It can contain HTML code, pictures, etc. The body consists of the data bytes transmitted in the HTTP message immediately following the header. Examples:5. Enter the URL in the browser and press Enter to request the process1. DNS resolution : When our browser searches its own DNS cache first, that is, our hosts file. If the browser's own cache cannot find it, it will check the system's DNS cache. If it is found and has not expired, the search and resolution will stop here. If the local machine does not find the DNS cache, the browser will initiate a DNS system call, and will initiate a domain name resolution request to the locally configured preferred DNS server, and will eventually find the IP address corresponding to our domain name. 2. TCP resolution : After obtaining the IP address corresponding to the domain name, the User-Agent (usually the browser) will initiate a TCP connection request to the server's WEB program (commonly used are httpd, nginx, etc.) port 80 with a random port (1024 < port < 65535). After the connection request reaches the server, it enters the network card, then enters the TCP/IP protocol stack of the kernel, and finally reaches the WEB program, finally establishing a TCP/IP connection. 3. Send HTTP request : After establishing a TCP connection, initiate an HTTP request 4. The server processes the request and returns an HTTP message : The server accepts and processes the request and returns an HTTP response. The format of a response message is basically the same as the request message, consisting of a response line, a response header, a blank line, and an entity. 5. Browser parses and renders the page 6. Connection ended : TCP waves four times, port connected 6. The difference between Cookie and Session6.1 Introduction to Cookies:
Cookie settings and sending process: 6.2 Session Introduction:
6.3 Differences between Cookies and Sessions
VII. ConclusionAt this point, the HTTP protocol has been explained. The above is Xiao Nong’s understanding of HTTP. |
<<: Internet services for the elderly have been standardized
>>: Aruba ESP Unveils New Enhancements to Secure Enterprises from Edge to Cloud
LiteServer is carrying out a promotion for its 15...
In places where high-density WI-FI terminals are ...
BuyVM is a foreign VPS hosting provider founded i...
SLS Alarm Management As a member of the Prometheu...
UCloud has recently launched a global cloud servi...
RAKsmart is a foreign hosting company operated by...
[Original article from 51CTO.com] Remember that t...
[51CTO.com original article] On April 25, Huawei&...
Xiao Yaqing, Minister of Industry and Information...
In the era of "Internet +", the rapid d...
In the quest for smarter and faster services, IT ...
During the COVID-19 pandemic, businesses have und...
V.PS is offering free default network upgrade to ...
CloudCone has launched a flash sale for 2021, off...
51CTO Network+ Platform launched the "TechNe...