Host
Host: www.example.com
User-Agent
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
Accept
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding
Accept-Encoding: gzip, deflate, br
Accept-Language
Accept-Language: en-US,en;q=0.5
Cache-Control
Cache-Control: no-cache
Connection
Connection: keep-alive
Authorization
Authorization: Basic dXNlcjpwYXNzd29yZA==
Content-Type
Content-Type: application/json
Content-Length
Content-Length: 348
Cookie
Cookie: sessionId=abc123; theme=light
Referer
Referer: https://www.google.com/
Origin
Origin: https://www.example.com
Range
Range: bytes=500-999
If-Modified-Since
If-Modified-Since: Wed, 21 Oct 2015 07:28:00 GMT
If-None-Match
If-Modified-Since
类似,用于判断资源是否被修改,基于 ETag 值。If-None-Match: "5d8c72a5f7e68e3ed89c71b3"
Strict-Transport-Security
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Requested-With
X-Requested-With: XMLHttpRequest
这些请求头帮助服务器理解客户端的能力、期望、权限等,并确保客户端和服务器之间的通信安全、有效。不同的请求头在不同的场景下有不同的使用方式,了解它们有助于开发更加安全和高效的应用程序。