Expect - HTTP 编辑
The Expect
HTTP request header indicates expectations that need to be fulfilled by the server in order to properly handle the request.
The only expectation defined in the specification is Expect: 100-continue
, to which the server shall respond with:
100
if the information contained in the header is sufficient to cause an immediate success,417
(Expectation Failed) if it cannot meet the expectation; or any other 4xx status otherwise.
For example, the server may reject a request if its Content-Length
is too large.
No common browsers send the Expect
header, but some other clients such as cURL do so by default.
Header type | Request header |
---|---|
Forbidden header name | yes |
Syntax
No other expectations except "100-continue" are specified currently.
Expect: 100-continue
Directives
- 100-continue
- Informs recipients that the client is about to send a (presumably large) message body in this request and wishes to receive a
100
(Continue) interim response.
Examples
Large message body
A client sends a request with a Expect header and waits for the server to respond before sending the message body.
PUT /somewhere/fun HTTP/1.1 Host: origin.example.com Content-Type: video/h264 Content-Length: 1234567890987 Expect: 100-continue
The server now checks the request headers and may respond with a 100
(Continue) response to instruct the client to go ahead and send the message body, or it will send a 417
(Expectation Failed) status if any of the expectations cannot be met.
Specifications
Specification | Title |
---|---|
RFC 7231, section 5.1.1: Expect | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论