100 Continue
The HTTP 100 Continue informational response
status code indicates the server is ready to accept
the message body. The client safely ignores this
response when the HTTP request is already complete.
The server sends this response only when the client
includes the Expect header with
100-continue.
Usage
Clients including the Expect header want to confirm the server is prepared to receive the message body before transmitting. When a message body is large, uses a content type the server does not accept, or the user lacks authorization to send files, this process validates those conditions before sending the body.
Once the 100 Continue status code arrives, the message body is sent. When the server returns 417 instead, the client does not continue.
The advantage of using the Expect header
with 100-continue is conserving bandwidth when the
server is selective about the content received and
processed.
The disadvantage is the HTTP request header and body are sent independently. Some environments are prone to having them separated and returning an error instead of processing the HTTP request.
Example
Request
PUT /docs HTTP/1.1
Host: www.example.re
Content-Type: application/pdf
Content-Length: 99000
Expect: 100-continue
Response
HTTP/1.1 100 Continue
Follow-up to request
<PDF file contents are sent as message body>
Final response
HTTP/1.1 200 OK
The client plans to send a 99 KB PDF file to the server for processing and indicates this in the HTTP request, asking for validation in advance. The server responds positively, and the client sends the message body. As a final response, the server concludes the HTTP session with a success indication.
Alternatively, the server responds with an error:
HTTP/1.1 417 Expectation Failed
In this situation, the client does not send the PDF, and further communication starts with a new HTTP request.
Expect100Continue in client libraries
Many HTTP client libraries expose
Expect100Continue as a configurable property.
In .NET, ServicePointManager.Expect100Continue
controls whether POST and PUT
requests automatically include the
Expect: 100-continue header. Disabling
this property skips the preliminary check and
sends the body immediately.
Code references
.NET
HttpStatusCode.Continue
Rust
http::StatusCode::CONTINUE
Rails
:continue
Go
http.StatusContinue
Symfony
Response::HTTP_CONTINUE
Python3.5+
http.HTTPStatus.CONTINUE
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_CONTINUE
Angular
@angular/common/http/HttpStatusCode.Continue