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/if-match/index.html | 89 ++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 files/zh-cn/web/http/headers/if-match/index.html (limited to 'files/zh-cn/web/http/headers/if-match') diff --git a/files/zh-cn/web/http/headers/if-match/index.html b/files/zh-cn/web/http/headers/if-match/index.html new file mode 100644 index 0000000000..9443a30e14 --- /dev/null +++ b/files/zh-cn/web/http/headers/if-match/index.html @@ -0,0 +1,89 @@ +--- +title: If-Match +slug: Web/HTTP/Headers/If-Match +tags: + - 条件请求 + - 首部 +translation_of: Web/HTTP/Headers/If-Match +--- +
{{HTTPSidebar}}
+ +

请求首部 If-Match 的使用表示这是一个条件请求。在请求方法为 {{HTTPMethod("GET")}} 和 {{HTTPMethod("HEAD")}} 的情况下,服务器仅在请求的资源满足此首部列出的 ETag值时才会返回资源。而对于 {{HTTPMethod("PUT")}} 或其他非安全方法来说,只有在满足条件的情况下才可以将资源上传。

+ +

{{HTTPHeader("ETag")}} 之间的比较使用的是强比较算法,即只有在每一个字节都相同的情况下,才可以认为两个文件是相同的。在 ETag 前面添加    W/ 前缀表示可以采用相对宽松的算法。

+ +

以下是两个常见的应用场景:

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

语法

+ +
If-Match: <etag_value>
+If-Match: <etag_value>, <etag_value>, …
+
+ +

指令

+ +
+
<etag_value>
+
唯一地表示一份资源的实体标签。标签是由 ASCII 字符组成的字符串,用双引号括起来(如 "675af34563dc-tr34")。前面可以加上 W/ 前缀表示应该采用弱比较算法。
+
*
+
星号是一个特殊值,可以指代任意资源。
+
+ +

示例

+ +
If-Match: "bfc13a64729c4290ef5b2c2730249c88ca92d82d"
+
+If-Match: W/"67ab43", "54ed21", "7892dd"
+
+If-Match: *
+
+ +

规范

+ + + + + + + + + + + + +
SpecificationTitle
{{RFC("7232", "If-Match", "3.1")}}Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests
+ +

浏览器兼容性

+ + + +

{{Compat("http.headers.If-Match")}}

+ +

相关内容

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