aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/methods/connect/index.html
blob: 27a0922fe540d28322f1ac75e529b1e7110c08aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
title: CONNECT
slug: Web/HTTP/Methods/CONNECT
tags:
  - 请求方法
  - 隧道
translation_of: Web/HTTP/Methods/CONNECT
---
<div>{{HTTPSidebar}}</div>

<p>在 HTTP 协议中,<strong><code>CONNECT</code> </strong>方法可以开启一个客户端与所请求资源之间的双向沟通的通道。它可以用来创建隧道(tunnel)。</p>

<p>例如,<strong><code>CONNECT</code> </strong>可以用来访问采用了 {{Glossary("SSL")}} ({{Glossary("HTTPS")}})  协议的站点。客户端要求代理服务器将 TCP 连接作为通往目的主机隧道。之后该服务器会代替客户端与目的主机建立连接。连接建立好之后,代理服务器会面向客户端发送或接收 TCP 消息流。</p>

<p><code>CONNECT</code> 是一个应用范围为点到点的方法。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Request has body</th>
   <td>No</td>
  </tr>
  <tr>
   <th scope="row">Successful response has body</th>
   <td>Yes</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Safe")}}</th>
   <td>No</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Idempotent")}}</th>
   <td>No</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Cacheable")}}</th>
   <td>No</td>
  </tr>
  <tr>
   <th scope="row">Allowed in <a href="/en-US/docs/Web/Guide/HTML/Forms">HTML forms</a></th>
   <td>No</td>
  </tr>
 </tbody>
</table>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">CONNECT www.example.com:443 HTTP/1.1
</pre>

<h2 id="示例">示例</h2>

<p>一些代理服务器在创建隧道时会要求进行身份验证。参见  {{HTTPHeader("Proxy-Authorization")}} 首部。</p>

<pre class="line-numbers  language-html">CONNECT server.example.com:80 HTTP/1.1
Host: server.example.com:80
Proxy-Authorization: basic aGVsbG86d29ybGQ=</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
  <tr>
   <td>{{RFC("7231", "CONNECT", "4.3.6")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{Compat("http.methods.CONNECT")}}</p>

<h2 id="相关内容">相关内容</h2>

<ul>
 <li>{{Glossary("Proxy server")}}</li>
 <li>{{HTTPHeader("Proxy-Authorization")}}</li>
</ul>