HTTP 与 Web 标准 / 知识点
HTTP Header 速查手册
基础与路由
Host: <host[:port]>指定目标主机与可选端口。
Host
指定目标主机与可选端口。
方向
请求
语法
Host: <host[:port]>示例
Host: api.example.com关键边界
HTTP/1.1 请求通常必须提供;HTTP/2/3 使用 :authority 表达对应权威信息。
User-Agent: <product>/<version>标识客户端软件。
User-Agent
标识客户端软件。
方向
请求
语法
User-Agent: <product>/<version>示例
User-Agent: Anystack-App/1.0关键边界
不应作为可信身份认证依据;浏览器正在逐步减少 UA 暴露信息。
Referer: <URL>表示当前请求来源页面地址。
Referer
表示当前请求来源页面地址。
方向
请求
语法
Referer: <URL>示例
Referer: https://example.com/docs关键边界
字段名历史上就是误拼写 Referer;可能受 Referrer-Policy 限制。
From: <mailbox>提供请求方控制者的联系邮箱。
From
提供请求方控制者的联系邮箱。
方向
请求
语法
From: <mailbox>示例
From: admin@example.com关键边界
极少用于普通浏览器/API 请求,不要拿它做认证。
Date: <HTTP-date>表示消息生成时间。
Date
表示消息生成时间。
方向
响应/请求
语法
Date: <HTTP-date>示例
Date: Wed, 26 Aug 2026 09:00:00 GMT关键边界
服务器响应常见;时间格式是 HTTP-date,不是任意本地时间格式。
Server: <product>描述源服务器软件信息。
Server
描述源服务器软件信息。
方向
响应
语法
Server: <product>示例
Server: nginx关键边界
可减少或隐藏过细版本信息,避免无必要暴露技术栈。
Allow: <method>, ...声明资源支持的 HTTP 方法。
Allow
声明资源支持的 HTTP 方法。
方向
响应
语法
Allow: <method>, ...示例
Allow: GET, HEAD, POST关键边界
常见于 405 响应,但也可出现在其他响应。
Location: <URI-reference>指定重定向目标或新建资源位置。
Location
指定重定向目标或新建资源位置。
方向
响应
语法
Location: <URI-reference>示例
Location: /users/123关键边界
3xx 常用于跳转;201 Created 也常用它指向新资源。
Retry-After: <HTTP-date|delay-seconds>告诉客户端多久后再重试。
Retry-After
告诉客户端多久后再重试。
方向
响应
语法
Retry-After: <HTTP-date|delay-seconds>示例
Retry-After: 120关键边界
常见于 503、429;客户端仍需自行实现退避策略。
Link: <target>; rel=<relation>用链接关系描述关联资源。
Link
用链接关系描述关联资源。
方向
响应/请求
语法
Link: <target>; rel=<relation>示例
Link: </style.css>; rel=preload; as=style关键边界
可表示 preload、canonical 等关系;一个字段可携带多个 link-value。
内容与协商
Accept: <media-range>声明客户端可接受的响应媒体类型。
Accept
声明客户端可接受的响应媒体类型。
方向
请求
语法
Accept: <media-range>示例
Accept: application/json关键边界
它描述响应偏好,不是请求 body 类型。
Accept-Encoding: <coding>, ...声明可接受的内容编码,如 gzip、br。
Accept-Encoding
声明可接受的内容编码,如 gzip、br。
方向
请求/响应
语法
Accept-Encoding: <coding>, ...示例
Accept-Encoding: gzip, br关键边界
与 Transfer-Encoding 不同;前者描述 representation 编码。
Accept-Language: <language-range>声明偏好的自然语言。
Accept-Language
声明偏好的自然语言。
方向
请求
语法
Accept-Language: <language-range>示例
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8关键边界
服务端是否采用取决于内容协商;常与 Vary 配合。
Accept-Charset: <charset>, ...历史上用于声明可接受字符集。
Accept-Charset
历史上用于声明可接受字符集。
方向
请求
语法
Accept-Charset: <charset>, ...示例
Accept-Charset: utf-8关键边界
IANA 已标记 deprecated;现代 HTTP 通常不要主动使用。
Content-Type: <media-type>[; charset=...]描述消息内容的媒体类型。
Content-Type
描述消息内容的媒体类型。
方向
请求/响应
语法
Content-Type: <media-type>[; charset=...]示例
Content-Type: application/json; charset=utf-8关键边界
不要和 Accept 混淆:Content-Type 描述当前内容,Accept 描述希望收到什么。
Content-Length: <octets>声明消息内容长度,单位字节。
Content-Length
声明消息内容长度,单位字节。
方向
请求/响应
语法
Content-Length: <octets>示例
Content-Length: 348关键边界
不要手工写错长度;HTTP/2/3 framing 不依赖它,但字段若存在仍必须正确。
Content-Encoding: <coding>说明 representation 在媒体类型之外还应用了何种内容编码。
Content-Encoding
说明 representation 在媒体类型之外还应用了何种内容编码。
方向
请求/响应
语法
Content-Encoding: <coding>示例
Content-Encoding: gzip关键边界
接收方通常先解码 Content-Encoding,再按 Content-Type 解释内容。
Content-Language: <language-tag>, ...声明内容面向的自然语言。
Content-Language
声明内容面向的自然语言。
方向
请求/响应
语法
Content-Language: <language-tag>, ...示例
Content-Language: zh-CN关键边界
它描述 representation,不等于客户端偏好的 Accept-Language。
Content-Location: <URI>表示当前 representation 对应的更具体资源位置。
Content-Location
表示当前 representation 对应的更具体资源位置。
方向
请求/响应
语法
Content-Location: <URI>示例
Content-Location: /docs/zh/index.html关键边界
不要和重定向用的 Location 混淆。
Content-Disposition: <type>; filename=<name>控制内容按 inline 展示还是 attachment 下载,并可建议文件名。
Content-Disposition
控制内容按 inline 展示还是 attachment 下载,并可建议文件名。
方向
响应/请求体部分
语法
Content-Disposition: <type>; filename=<name>示例
Content-Disposition: attachment; filename="report.pdf"关键边界
HTTP 响应下载很常见;multipart 中也用于描述表单 part。