4174xx
4xx — Client Error
Expectation Failed
This response code means the expectation indicated by the Expect request header field cannot be met by the server.
What it means
The HTTP 417 Expectation Failed client error response code indicates that the expectation given in the request's `Expect` header could not be met.
Clients sometimes use `Expect: 100-continue` to ask the server if they are allowed to upload a large file before actually sending the massive payload.
How it works
- 1The client wants to upload a 5GB file.
- 2Instead of sending the data immediately, it sends just the headers with `Expect: 100-continue`.
- 3The server checks the user's quota. The user is out of space.
- 4Instead of returning 100 Continue, the server returns 417 (or 403/413). The client knows to abort without wasting 5GB of bandwidth.
Why you're seeing this
- • The server does not support the Expect header, or actively rejects the preconditions.
How to fix it
- • If you encounter this as a client, you can reconfigure your HTTP library to stop sending the `Expect` header.
Framework Implementations
Node.js (http)
server.on('checkContinue', (req, res) => {
if (!userHasQuota(req)) {
res.writeContinue(); // 100 Continue
} else {
res.writeHead(417);
res.end();
}
});Real-Life Scenarios
Use this strictly when handling HTTP/1.1 `Expect: 100-continue` logic in a low-level server environment to reject a request before the body is received.
Aborted File Upload
Curl sends an Expect header before uploading a huge ISO file. The proxy server refuses the connection based on the URL and sends 417.
HTTP Transaction
1. Client Request
POST /upload HTTP/1.1 Expect: 100-continue Content-Length: 5000000000
2. Server Response
HTTP/1.1 417 Expectation Failed Connection: close
SEO Implications
None.