From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/http/headers/warning/index.html | 141 ++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 files/zh-cn/web/http/headers/warning/index.html (limited to 'files/zh-cn/web/http/headers/warning') diff --git a/files/zh-cn/web/http/headers/warning/index.html b/files/zh-cn/web/http/headers/warning/index.html new file mode 100644 index 0000000000..1b2cdcd452 --- /dev/null +++ b/files/zh-cn/web/http/headers/warning/index.html @@ -0,0 +1,141 @@ +--- +title: Warning +slug: Web/HTTP/Headers/Warning +tags: + - 警告 + - 警告码 + - 通用首部 +translation_of: Web/HTTP/Headers/Warning +--- +
{{HTTPSidebar}}
+ +

Warning 是一个通用报文首部,包含报文当前状态可能存在的问题。在响应中可以出现多个 Warning 首部。

+ +

一般来说, Warning 首部可以应用于任何类型的报文。然而一部分警告码(warn-code)是为缓存代理服务器定制的,并且只可以应用在响应报文中。

+ + + + + + + + + + + + +
Header type{{Glossary("General header")}}
{{Glossary("Forbidden header name")}}no
+ +

语法

+ +
Warning: <warn-code> <warn-agent> <warn-text> [<warn-date>]
+
+ +

指令

+ +
+
<warn-code>
+
三位数字警告码。第一位数字表示 Warning 信息在验证之后是否需要从已存储的响应中删除。 +
    +
  • 1xx 警告码描述了关于当前响应的新鲜度或者验证状态的警告信息,并且将会在验证之后被缓存服务器删除。
  • +
  • +

    2xx 警告码描述了验证之后不会被修复的某些展现内容方面的警告信息,并且在验证之后不会被缓存服务器删除。

    +
  • +
+
+
<warn-agent>
+
+

添加到 Warning 首部的服务器或者软件的名称或者伪名称(当代理不可知的时候可以用 "-" 代替)。

+
+
<warn-text>
+
用来描述错误信息的警告文本。
+
<warn-date>
+
可选。假如多个 Warning 被发送,那么需包含一个与 {{HTTPHeader("Date")}} 首部相对应的日期字段。
+
+ +

警告码

+ +

由 iana.org 维护的 HTTP 警告码登记表规定了警告码的命名空间。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
码值文字描述详细说明
110Response is Stale由缓存服务器提供的响应已过期(设置的失效时间已过)。
111Revalidation Failed 由于无法访问服务器,响应验证失败。
112Disconnected Operation缓存服务器断开连接。
113Heuristic Expiration如果缓存服务器采用启发式方法,将缓存的有效时间设定为24小时,而在该响应的年龄超过24小时时发送。
199Miscellaneous Warning任意的、未明确指定的警告信息。
214Transformation Applied由代理服务器添加,如果它对返回的展现内容进行了任何转换,比如改变了内容编码、媒体类型等。
299Miscellaneous Warning与199类似,只不过指代的是持久化警告。
+ +

示例

+ +
Warning: 110 anderson/1.3.37 "Response is stale"
+
+Date: Wed, 21 Oct 2015 07:28:00 GMT
+Warning: 112 - "cache down" "Wed, 21 Oct 2015 07:28:00 GMT"
+
+ +

规范

+ + + + + + + + + + + + +
SpecificationTitle
{{RFC("7234", "Warning", "5.5")}}Hypertext Transfer Protocol (HTTP/1.1): Caching
+ +

浏览器兼容性

+ + + +

{{Compat("http.headers.Warning")}}

+ +

相关内容

+ + -- cgit v1.2.3-54-g00ecf