HTTP request parsing

mirew 2022-02-13 06:08:09 阅读数:154

http request parsing

HTTP Request initiated by client , It refers to the request message from the client to the server .

How to initiate HTTP request

With the help of HTTP Tools and know URL You can initiate this HTTP request .

for example :

  Type one in the browser address bar URL, Press enter to initiate this HTTP request .

  URL( Uniform resource locator / website ) The format is :

       agreement :// The server IP Address (: port )/ route /(? Inquire about )              // The default port can be omitted , The query section may not notes :

1. IP An address is a logical address used to uniquely identify a computer on the Internet . Every networked computer depends on IP Address to distinguish each other 、 contact . but IP The address is a digital id , Difficult to remember and write , So in IP Based on the address, a symbolic address scheme is developed , Instead of Digital IP Address . Each symbolic address is associated with a specific IP The address corresponds to . This is similar to the digital type on the network IP The character type address corresponding to the address , It's called a domain name . Multiple domain names can resolve one at the same time ip, But one domain name cannot resolve more than one ip.

2. Ports can be omitted , Use the default port when omitted ,HTTP Protocol default port number 80,HTTPS Protocol default port number 443.

for example :

 https :// /baidu ?tn=monline_7_dg&ie=utf-8&wd=1   

agreement :// The server IP Address ( domain name )/ route ? Inquire about         

        https :// /html/html_jianjie.asp

agreement :// The server IP Address ( domain name )/ route ( Hierarchical file path )/

stay Linux You can use curl Command initiation HTTP request ,Windows You can use curl.exe Tools ( Download by yourself ).

HTTP Request format

HTTP The request consists of three parts : Request line 、 Request header 、 Request body .( You can press... In the browser F12 see )


POST /page/index/checkCode.php HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:94.0) Gecko/20100101 Firefox/94.0
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Length: 17


The first line is the request line ;
The composition is as follows : Request method (POST) / The requested address under the root directory of the domain name (/page/index/checkCode.php) / Protocol and version used (HTTP 1.1 edition )

The second line to the blank line are the request header , Additional information passed from the client to the server , It can also transfer the information of the client itself .

The last line is the request body .( Most often in POST request ,GET Request has no request body )

HTTP Request method


GET Method is used to get the specified information of the request page , Return the entity body . When we open and browse an ordinary web page, we usually GET request , For example, now click to open this blog (


And GET be similar , The difference is POST The request has a request subject , Used to transfer a large amount of data to the server , And the information will not be displayed in URL in , comparison GET More secure . For uploading files , Login, registration, etc .

notes :GET Ask for something to do with POST Request differentiation



Except that the message body is not returned , And GET identical , Used to get the message header ( Response head ). You can test the effectiveness of a resource ( You can understand the content stored in the response header ), Because the message subject is not returned ( Response Content ) So it's very fast .


  You can save the entity part of the request under the requested resource , If the requested resource already exists in the server , The original requested resource will be replaced with the entity part in the request . Used to create a new resource or replace a specified resource .


Used to request the deletion of the specified resource requested by the server .


Can echo the request received by the server , So that the user can understand the reception of the party whose data is requested and use it for diagnosis and debugging .


This method is used for proxy servers that can change the connection to pipeline .


It is used to request to obtain the function options that can be used in the communication process of the requested resource , Or check the performance of the server .

Request header

Used only for HTTP In request , It can make the client pass the client's own information to the server , Additional information .


copyright:author[mirew],Please bring the original link to reprint, thank you.