From 310fd066e91f454b990372ffa30e803cc8120975 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 12:56:40 +0100 Subject: unslug zh-cn: move --- .../index.html" | 44 ---------------------- 1 file changed, 44 deletions(-) delete mode 100644 "files/zh-cn/glossary/\350\257\267\346\261\202\345\244\264/index.html" (limited to 'files/zh-cn/glossary/请求头/index.html') diff --git "a/files/zh-cn/glossary/\350\257\267\346\261\202\345\244\264/index.html" "b/files/zh-cn/glossary/\350\257\267\346\261\202\345\244\264/index.html" deleted file mode 100644 index 666ace7ea4..0000000000 --- "a/files/zh-cn/glossary/\350\257\267\346\261\202\345\244\264/index.html" +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Request header(请求头) -slug: Glossary/请求头 -tags: - - HTTP - - 术语 -translation_of: Glossary/Request_header ---- -

请求头是 {{glossary("header", "HTTP 头")}}的一种,它可在 HTTP 请求中使用,并且和请求主体无关 。某些请求头如 {{HTTPHeader("Accept")}}、{{HTTPHeader("Accept-Language", "Accept-*")}}、 {{HTTPHeader("If-Modified-Since", "If-*")}} 允许执行条件请求。某些请求头如:{{HTTPHeader("Cookie")}}, {{HTTPHeader("User-Agent")}} 和 {{HTTPHeader("Referer")}} 描述了请求本身以确保服务端能返回正确的响应。

- -

并非所有出现在请求中的 HTTP 首部都属于请求头,例如在 {{HTTPMethod("POST")}} 请求中经常出现的 Content-Length 实际上是一个代表请求主体大小的 entity header,虽然你也可以把它叫做请求头。

- -

此外,CORS 定义了一个叫做 {{glossary('simple header', 'simple headers')}} 的集合,它是请求头集合的一个子集。如果某次请求是只包含 {{glossary('simple header', 'simple header')}} 的话,则被认为是简单请求,不会触发请求预检({{glossary("preflight request", "preflight")}})。

- -

下面是一个 HTTP 请求的请求头:

- -
GET /home.html HTTP/1.1
-Host: developer.mozilla.org
-User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
-Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
-Accept-Language: en-US,en;q=0.5
-Accept-Encoding: gzip, deflate, br
-Referer: https://developer.mozilla.org/testpage.html
-Connection: keep-alive
-Upgrade-Insecure-Requests: 1
-If-Modified-Since: Mon, 18 Jul 2016 02:36:04 GMT
-If-None-Match: "c561c68d0ba92bbeb8b0fff2a9199f722e3a621a"
-Cache-Control: max-age=0
- -

严格来说在这个例子中的 {{HTTPHeader("Content-Length")}} 不是一个请求头,而是一个实体头({{glossary("entity header")}}):

- -
POST /myform.html HTTP/1.1
-Host: developer.mozilla.org
-User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
-Content-Length: 128
-
- -

深入了解

- -

技术信息

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