HTTP request message response message

Back to the general list of articles

One, HTTP explanation

HTTP (hypertext transport protocol) protocol [Hypertext Transfer Protocol]
protocol specifies the rules for communication between browsers and World Wide Web servers in detail

Two, request message and response message

Types of requests, here are two

GET请求      请求体可以没有
POST请求		请求体可以有

Request message

1.GET
response header: most of the information in the format is name+colon+space+parameter

'''
请求行	GET /s?ie=utf-8 HTTP/1.1
请求头	Host: www.baidu.com
		Cookie: name=dalao
		Conten-type: applocation/x-www-form-url
		User-Agent: chrome 99
空行
请求体	username=admin&password=admin
'''

2.POST
response header: most of the information in the format is name+colon+space+parameter

'''
请求行	POST /s?ie=utf-8 HTTP/1.1
请求头	Host: www.baidu.com
		Cookie: name=dalao
		Conten-type: applocation/x-www-form-url
		User-Agent: chrome 99
空行
请求体	username=admin&password=admin
'''

Response message

Response header: Most of the information in the format is name+colon+space+parameter

'''
响应行	HTTP/1.1	200	OK	1.(协议版本:HTTP/1.1)   2.(响应状态码:200:)   3.(响应状态字符串:OK)
响应头	Content-Type: text/html;charset=utf-8   类型
		Content-length: 2048	长度
		Content-encoding:gizp 	压缩方式
空行
响应体	<html>
			<head>
			</head>
			<body>
				<h1>网页文字</h1>
			</body>
		</html>
		
'''

Show example

In Google Chrome.
1. Press F12 to enter the developer interface, and then click on the column Network.
Under this Netword tag, all the sending and request of our current webpage are listed in the name display. And received file information.

2. Enter luichun in the search box of the Baidu page on the left to search, press Enter
and refresh the page again

3. Click the first file in Name.
Baidu search is s?ie=utf-8&...
Google search is search?q=luichun...
Insert picture description here

Insert picture description here

Then it will jump out of another window,

Headers 头部信息
Preview 响应的预览
Response 响应
Initiator 发起者
Timing 计时
Cookies 储存在用户本地终端上的数据(通常经过加密)

There are four tabs under Headers

General 大体的
Response Headers 响应头
Request Headers 请求头
Query String Parameters 查询字符串参数

Insert picture description here

1.Request Headers
In Baidu, click on the view source in the small print on the right to view the request method GET through Request Headers in Baidu, click
directly on the Request Headers to view the calling method GET

The request behavior in Baidu is
GET (request method) + url (IP address) + HTTP1.1 (protocol version)
Google's will not explain
Insert picture description here

2.Query String Parameters Query string parameters
are the analysis of the parameters of the url in the request line (formatting is convenient for us to adjust later)
Insert picture description here
3.Response Headers
View the original response message
Click on the view source in the small print on the right to view the original response Message
Insert picture description here

To view the response body, click on the Response
html tag text css style js code in the upper window, etc.
Insert picture description here

4. The content of the request body is requested
by the post method, and the login will use this method. Show
the form data in the login file. The login information is recorded in the form data. The
mailbox and password are recorded.
Then its response is empty. Jump, it has no effect on us
Insert picture description here

to sum up

响应报文  1.Response(响应体) 
		 2.Response Headers(响应行)
		 
请求报文 
		 1.Request Headers(请求行) 
		 2.From Data(请求体)

About HTTP2, you can browse
https://nodejs.org/api/http2.html#http2_http_2

Guess you like

Origin blog.csdn.net/weixin_47021806/article/details/111871642