diff options
Diffstat (limited to 'files/zh-tw/web/http/methods')
-rw-r--r-- | files/zh-tw/web/http/methods/connect/index.html | 82 | ||||
-rw-r--r-- | files/zh-tw/web/http/methods/get/index.html | 69 | ||||
-rw-r--r-- | files/zh-tw/web/http/methods/index.html | 63 | ||||
-rw-r--r-- | files/zh-tw/web/http/methods/post/index.html | 124 |
4 files changed, 338 insertions, 0 deletions
diff --git a/files/zh-tw/web/http/methods/connect/index.html b/files/zh-tw/web/http/methods/connect/index.html new file mode 100644 index 0000000000..0b44ddec87 --- /dev/null +++ b/files/zh-tw/web/http/methods/connect/index.html @@ -0,0 +1,82 @@ +--- +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 class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.methods.CONNECT")}}</p> + +<h2 id="參見">參見</h2> + +<ul> + <li>{{Glossary("Proxy server")}}</li> + <li>{{HTTPHeader("Proxy-Authorization")}}</li> +</ul> diff --git a/files/zh-tw/web/http/methods/get/index.html b/files/zh-tw/web/http/methods/get/index.html new file mode 100644 index 0000000000..654d4a3d3d --- /dev/null +++ b/files/zh-tw/web/http/methods/get/index.html @@ -0,0 +1,69 @@ +--- +title: GET +slug: Web/HTTP/Methods/GET +translation_of: Web/HTTP/Methods/GET +--- +<div>{{HTTPSidebar}}</div> + +<p><strong>HTTP <code>GET</code> method</strong> 方法請求展示指定資源。 使用 <code>GET</code> 的請求只應用於取得資料。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">Request 有 body</th> + <td>No</td> + </tr> + <tr> + <th scope="row">成功的 response 有 body</th> + <td>Yes</td> + </tr> + <tr> + <th scope="row">{{Glossary("Safe")}}</th> + <td>Yes</td> + </tr> + <tr> + <th scope="row">{{Glossary("Idempotent")}}</th> + <td>Yes</td> + </tr> + <tr> + <th scope="row">{{Glossary("Cacheable")}}</th> + <td>Yes</td> + </tr> + <tr> + <th scope="row">允許在 HTML 表單</th> + <td>Yes</td> + </tr> + </tbody> +</table> + +<h2 id="格式">格式</h2> + +<pre class="syntaxbox">GET /index.html +</pre> + +<h2 id="規範">規範</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">規範</th> + <th scope="col">標題</th> + </tr> + <tr> + <td>{{RFC("7231", "GET", "4.3.1")}}</td> + <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td> + </tr> + </tbody> +</table> + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.methods.GET")}}</p> + +<h2 id="參見">參見</h2> + +<ul> + <li>{{HTTPHeader("Range")}}</li> +</ul> diff --git a/files/zh-tw/web/http/methods/index.html b/files/zh-tw/web/http/methods/index.html new file mode 100644 index 0000000000..fb44615883 --- /dev/null +++ b/files/zh-tw/web/http/methods/index.html @@ -0,0 +1,63 @@ +--- +title: HTTP 請求方法 +slug: Web/HTTP/Methods +translation_of: Web/HTTP/Methods +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP 定義了一組能令給定資源,執行特定操作的<strong>請求方法</strong>(request methods)。他們儘管屬於名詞,但也能稱為 <em>HTTP 動詞</em>。每個方法都有不同的語意,不過也有些共享的相通功能,像是{{glossary("safe")}}、{{glossary("idempotent")}}、{{glossary("cacheable")}}。</p> + +<dl> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/GET">GET</a></code></dt> + <dd><code>GET</code> 方法請求展示指定資源。使用 <code>GET</code> 的請求只應用於取得資料。</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/HEAD">HEAD</a></code></dt> + <dd><code>HEAD</code> 方法請求與 <code>GET</code> 方法相同的回應,但它沒有回應主體(response body)。</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/POST">POST</a></code></dt> + <dd><code>POST</code> 方法用於提交指定資源的實體,通常會改變伺服器的狀態或副作用(side effect)。</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/PUT">PUT</a></code></dt> + <dd><code>PUT</code> 方法會取代指定資源所酬載請求(request payload)的所有表現。</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/DELETE">DELETE</a></code></dt> + <dd><code>DELETE</code> 方法會刪除指定資源.</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/CONNECT">CONNECT</a></code></dt> + <dd><code>CONNECT</code> 方法會和指定資源標明的伺服器之間,建立隧道(tunnel)。</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/OPTIONS">OPTIONS</a></code></dt> + <dd><code>OPTIONS</code> 方法描述指定資源的溝通方法(communication option)。</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/TRACE">TRACE</a></code></dt> + <dd><code>TRACE</code> 方法會與指定資源標明的伺服器之間,執行迴路返回測試(loop-back test)。</dd> + <dt><code><a href="/zh-TW/docs/Web/HTTP/Methods/PATCH">PATCH</a></code></dt> + <dd><code>PATCH</code> 方法套用指定資源的部份修改。</dd> +</dl> + +<h2 id="規範">規範</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">規範</th> + <th scope="col">標題</th> + <th scope="col">註解</th> + </tr> + <tr> + <td>{{RFC("7231", "Request methods", "4")}}</td> + <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td> + <td>Specifies GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE.</td> + </tr> + <tr> + <td>{{RFC("5789", "Patch method", "2")}}</td> + <td>PATCH method for HTTP</td> + <td>Specifies PATCH.</td> + </tr> + </tbody> +</table> + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +<p class="hidden">To contribute to this compatibility data, please write a pull request against this file: <a href="https://github.com/mdn/browser-compat-data/blob/master/http/methods.json">https://github.com/mdn/browser-compat-data/blob/master/http/methods.json</a>.</p> + +<p>{{Compat("http/methods")}}</p> + +<h2 id="參見">參見</h2> + +<ul> + <li><a href="/zh-TW/docs/Web/HTTP/Headers">HTTP 標頭</a></li> +</ul> diff --git a/files/zh-tw/web/http/methods/post/index.html b/files/zh-tw/web/http/methods/post/index.html new file mode 100644 index 0000000000..3332297535 --- /dev/null +++ b/files/zh-tw/web/http/methods/post/index.html @@ -0,0 +1,124 @@ +--- +title: POST +slug: Web/HTTP/Methods/POST +translation_of: Web/HTTP/Methods/POST +--- +<div>{{HTTPSidebar}}</div> + +<p>The <strong>HTTP <code>POST</code> method</strong> sends data to the server. The type of the body of the request is indicated by the {{HTTPHeader("Content-Type")}} header.</p> + +<p>The difference between <code>PUT</code> and {{HTTPMethod("POST")}} is that <code>PUT</code> is idempotent: calling it once or several times successively has the same effect (that is no <em>side</em> effect), where successive identical <code>POST</code> may have additional effects, like passing an order several times.</p> + +<p>A <code>POST</code> request is typically sent via an <a href="/en-US/docs/Web/Guide/HTML/Forms">HTML form</a> and results in a change on the server. In this case, the content type is selected by putting the adequate string in the {{htmlattrxref("enctype", "form")}} attribute of the {{HTMLElement("form")}} element or the {{htmlattrxref("formenctype", "input")}} attribute of the {{HTMLElement("input") }} or {{HTMLElement("button")}} elements:</p> + +<ul> + <li><code>application/x-www-form-urlencoded</code>: the keys and values are encoded in key-value tuples separated by <code>'&'</code>, with a <code>'='</code> between the key and the value. Non-alphanumeric characters in both keys and values are {{glossary("percent-encoding", "percent encoded")}}: this is the reason why this type is not suitable to use with binary data (use <code>multipart/form-data</code> instead)</li> + <li><code>multipart/form-data</code>: each value is sent as a block of data ("body part"), with a user agent-defined delimiter ("boundary") separating each part. The keys are given in the <code>Content-Disposition</code> header of each part.</li> + <li><code>text/plain</code></li> +</ul> + +<p>When the <code>POST</code> request is sent via a method other than an HTML form — like via an {{domxref("XMLHttpRequest")}} — the body can take any type. As described in the HTTP 1.1 specification, <code>POST</code> is designed to allow a uniform method to cover the following functions:</p> + +<ul> + <li>Annotation of existing resources</li> + <li>Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;</li> + <li>Adding a new user through a signup modal;</li> + <li>Providing a block of data, such as the result of submitting a form, to a data-handling process;</li> + <li>Extending a database through an append operation.</li> +</ul> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">Request has body</th> + <td>Yes</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>Only if freshness information is included</td> + </tr> + <tr> + <th scope="row">Allowed in <a href="/en-US/docs/Web/Guide/HTML/Forms">HTML forms</a></th> + <td>Yes</td> + </tr> + </tbody> +</table> + +<h2 id="格式">格式</h2> + +<pre class="syntaxbox">POST /test +</pre> + +<h2 id="範例">範例</h2> + +<p>使用 <code>application/x-www-form-urlencoded</code> 內容類型的簡易表單:</p> + +<pre class="line-numbers language-html">POST /test HTTP/1.1 +Host: foo.example +Content-Type: application/x-www-form-urlencoded +Content-Length: 27 + +field1=value1&field2=value2</pre> + +<p>使用 <code>multipart/form-data</code> 內容類型的表單:</p> + +<pre>POST /test HTTP/1.1 +Host: foo.example +Content-Type: multipart/form-data;boundary="boundary" + +--boundary +Content-Disposition: form-data; name="field1" + +value1 +--boundary +Content-Disposition: form-data; name="field2"; filename="example.txt" + +value2 +--boundary-- +</pre> + +<h2 id="規範">規範</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">規範</th> + <th scope="col">標題</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{RFC("7231", "POST", "4.3.3")}}</td> + <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td> + </tr> + <tr> + <td>{{RFC("2046", "Common Syntax", "5.1.1")}}</td> + <td>Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</td> + </tr> + </tbody> +</table> + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.methods.POST")}}</p> + +<h2 id="參見">參見</h2> + +<ul> + <li>{{HTTPHeader("Content-Type")}}</li> + <li>{{HTTPHeader("Content-Disposition")}}</li> +</ul> |