Expect

The HTTP Expect request header is sent by a client to check, in advance of sending a message body, whether the server can meet the requirements of the HTTP request.

Table of Contents

Usage

The HTTP Expect header is generated by the client in advance of sending the message body. For example, if the HTTP request for an HTTP PUT requires saving a large file, the server can check local storage capacity to determine whether the HTTP request can succeed.

The only directive available is 100-continue, as follows:

Expect: 100-continue

If upon examining the HTTP headers of the message, the server can meet the expectations, then it will return HTTP status 100 Continue, signaling the client to send the message body.

If the server is unable to satisfy the requirements then it will return HTTP error 417 Expectation Failed. This can happen, for example, after reading the HTTP Content-Length header and recognizing that local storage space is insufficient to satisfy the HTTP request. Ultimately, the bandwidth required to send the message body is not wasted if the server knows in advance that the HTTP request must fail.

Takeaway

The HTTP Expect header is included by a client to inform the server about expectations that it has for the HTTP request, in advance of sending the message body. It is intended as a bandwidth-preserving technique for situations where the server is unable to process the HTTP request.

See also

Last updated: June 2, 2022