aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/headers/expect
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/http/headers/expect
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/http/headers/expect')
-rw-r--r--files/zh-cn/web/http/headers/expect/index.html87
1 files changed, 87 insertions, 0 deletions
diff --git a/files/zh-cn/web/http/headers/expect/index.html b/files/zh-cn/web/http/headers/expect/index.html
new file mode 100644
index 0000000000..afc4da4bce
--- /dev/null
+++ b/files/zh-cn/web/http/headers/expect/index.html
@@ -0,0 +1,87 @@
+---
+title: Expect
+slug: Web/HTTP/Headers/Expect
+translation_of: Web/HTTP/Headers/Expect
+---
+<div>{{HTTPSidebar}}</div>
+
+<p><strong><code>Expect</code></strong> 是一个请求消息头,包含一个期望条件,表示服务器只有在满足此期望条件的情况下才能妥善地处理请求。</p>
+
+<p>规范中只规定了一个期望条件,即 <code>Expect: 100-continue</code>, 对此服务器可以做出如下回应:</p>
+
+<ul>
+ <li>{{HTTPStatus("100")}} 如果消息头中的期望条件可以得到满足,使得请求可以顺利进行的话,</li>
+ <li>{{HTTPStatus("417")}} (Expectation Failed) 如果服务器不能满足期望条件的话;也可以是其他任意表示客户端错误的状态码(4xx)。</li>
+</ul>
+
+<p>例如,如果请求中 {{HTTPHeader("Content-Length")}} 的值太大的话,可能会遭到服务器的拒绝。</p>
+
+<p>常见的浏览器不会发送 <code>Expect</code> 消息头,但是其他类型的客户端如cURL默认会这么做。</p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row">Header type</th>
+ <td>{{Glossary("Request header")}}</td>
+ </tr>
+ <tr>
+ <th scope="row">{{Glossary("Forbidden header name")}}</th>
+ <td>no</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="语法">语法</h2>
+
+<p>目前规范中只规定了 "100-continue" 这一个期望条件。</p>
+
+<pre class="syntaxbox">Expect: 100-continue
+</pre>
+
+<h2 id="指令">指令</h2>
+
+<dl>
+ <dt>100-continue</dt>
+ <dd>通知接收方客户端要发送一个体积可能很大的消息体,期望收到状态码为{{HTTPStatus("100")}} (Continue)  的临时回复。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="大消息体">大消息体</h3>
+
+<p>客户端发送带有Expect消息头的请求,等服务器回复后再发送消息体。</p>
+
+<pre>PUT /somewhere/fun HTTP/1.1
+Host: origin.example.com
+Content-Type: video/h264
+Content-Length: 1234567890987
+Expect: 100-continue
+</pre>
+
+<p>服务器开始检查请求消息头,可能会返回一个状态码为 {{HTTPStatus("100")}} (Continue) 的回复来告知客户端继续发送消息体,也可能会返回一个状态码为{{HTTPStatus("417")}} (Expectation Failed) 的回复来告知对方要求不能得到满足。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Title</th>
+ </tr>
+ <tr>
+ <td>{{RFC("7231", "Expect", "5.1.1")}}</td>
+ <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容情况">浏览器兼容情况</h2>
+
+<p>目前没有已知的浏览器会使用这个消息头。</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{HTTPStatus("417")}}<code> Expectation Failed</code></li>
+ <li>{{HTTPStatus("100")}}<code> Continue</code></li>
+</ul>