--- title: CONNECT slug: Web/HTTP/Methods/CONNECT translation_of: Web/HTTP/Methods/CONNECT --- <div>{{HTTPSidebar}}</div> <p><strong>HTTP <code>CONNECT</code> </strong>方法會利用請求資源啟動一個雙向通訊。這通常可用於建立隧道。</p> <p>舉例來說,<code>CONNECT </code>方法可以用於存取使用 {{Glossary("SSL")}} ({{Glossary("HTTPS")}}) 的網站。客戶端請求 HTTP Proxy 伺服器建立 TCP 連結的隧道到指定的位置。伺服器接著代表客戶端建立連結。一但連結建立,Proxy 伺服器會持續收送 TCP 流到客戶端。</p> <p><code>CONNECT</code> 是個逐跳方法。</p> <table class="properties"> <tbody> <tr> <th scope="row">請求具有 Body</th> <td>否</td> </tr> <tr> <th scope="row">成功回覆具有 Body</th> <td>是</td> </tr> <tr> <th scope="row">{{Glossary("Safe")}}</th> <td>否</td> </tr> <tr> <th scope="row">{{Glossary("Idempotent")}}</th> <td>否</td> </tr> <tr> <th scope="row">{{Glossary("Cacheable")}}</th> <td>否</td> </tr> <tr> <th scope="row">可用於 <a href="/zh-TW/docs/Web/Guide/HTML/Forms">HTML 表單</a></th> <td>否</td> </tr> </tbody> </table> <h2 id="語法">語法</h2> <pre class="syntaxbox">CONNECT www.example.com:443 HTTP/1.1 </pre> <h2 id="範例">範例</h2> <p>有些 Proxy 伺服器也許需要授權以建立隧道。請見 {{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">規格</th> <th scope="col">標題</th> </tr> <tr> <td>{{RFC("7231", "CONNECT", "4.3.6")}}</td> <td>超文本轉送協議 (HTTP/1.1): 語意與內容</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>