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/connection/index.html | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 files/zh-cn/web/http/headers/connection/index.html (limited to 'files/zh-cn/web/http/headers/connection') diff --git a/files/zh-cn/web/http/headers/connection/index.html b/files/zh-cn/web/http/headers/connection/index.html new file mode 100644 index 0000000000..49ed469262 --- /dev/null +++ b/files/zh-cn/web/http/headers/connection/index.html @@ -0,0 +1,55 @@ +--- +title: Connection +slug: Web/HTTP/Headers/Connection +tags: + - HTTP + - Web + - 参考 + - 头部 +translation_of: Web/HTTP/Headers/Connection +--- +
{{HTTPSidebar}}
+ +

Connection 头(header) 决定当前的事务完成后,是否会关闭网络连接。如果该值是“keep-alive”,网络连接就是持久的,不会关闭,使得对同一个服务器的请求可以继续在该连接上完成。

+ +
+

 特定于连接的标头字段(例如Connection)不得与HTTP / 2一起使用。

+
+ +

除去标准的逐段传输(hop-by-hop)头({{HTTPHeader("Keep-Alive")}}, {{HTTPHeader("Transfer-Encoding")}}, {{HTTPHeader("TE")}}, {{HTTPHeader("Connection")}}, {{HTTPHeader("Trailer")}}, {{HTTPHeader("Upgrade")}}, {{HTTPHeader("Proxy-Authorization")}} and {{HTTPHeader("Proxy-Authenticate")}}),任何逐段传输头都需要在 Connection 头中列出,这样才能让第一个代理知道必须处理它们且不转发这些头。标准的逐段传输头也可以列出(常见的例子是 {{HTTPHeader("Keep-Alive")}},但这不是必须的)。

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

语法

+ +
Connection: keep-alive
+Connection: close
+
+ +

指令

+ +
+
close
+
表明客户端或服务器想要关闭该网络连接,这是HTTP/1.0请求的默认值
+
+
以逗号分隔的HTTP头 [通常仅有 keep-alive]
+
表明客户端想要保持该网络连接打开,HTTP/1.1的请求默认使用一个持久连接。这个请求头列表由头部名组成,这些头将被第一个非透明的代理或者代理间的缓存所移除:这些头定义了发出者和第一个实体之间的连接,而不是和目的地节点间的连接。
+
+
+ +

浏览器兼容性

+ + + +
{{Compat("http.headers.Connection")}}
-- cgit v1.2.3-54-g00ecf