/ HTTP Status Codes

100 Continue

The HTTP 100 Continue status code is part of the HTTP/1.1 standard and is sent as an interim response by the server to indicate that it has received the request headers and the client can proceed to send the request body (if any). This status code is used primarily to allow the client to continue or abort the request based on the server’s response.

When to Use 100 Continue

The 100 Continue status code is typically used when the client sends a request with the Expect: 100-continue header. This header is used by the client to inform the server that it expects a 100 Continue status code before sending the request body.

The primary use case for this mechanism is to allow the client to avoid sending large request bodies when the server might reject the request based on the headers alone, such as when the client does not have proper authentication or the server is unable to process the request for some reason.

Server Behavior

When a server receives a request with the Expect: 100-continue header, it should respond with either a 100 Continue status code, indicating that the client should send the request body, or with a final status code (e.g., 400 Bad Request or 401 Unauthorized) indicating that the client should not send the request body and the request has been rejected.

If the server does not support the Expect header, it should ignore it and proceed with processing the request as usual.

Example

Here is an example of a client sending a request with the Expect: 100-continue header:

POST /upload HTTP/1.1
Host: example.com
Content-Type: application/octet-stream
Content-Length: 12345
Expect: 100-continue

In this case, the server should respond with either a 100 Continue status code or a final status code.

100 Continue Response

If the server accepts the request, it should respond with a 100 Continue status code:

HTTP/1.1 100 Continue

After receiving this response, the client can proceed to send the request body.

Final Status Code Response

If the server rejects the request based on the headers, it should respond with a final status code, such as 400 Bad Request or 401 Unauthorized:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Restricted"
Content-Type: text/html
Content-Length: 56

<html><body><h1>401 Unauthorized</h1></body></html>

In this case, the client should not send the request body and should handle the error accordingly.

Summary

The 100 Continue status code is an interim response sent by the server to indicate that it has received the request headers and the client can proceed to send the request body. This mechanism is used primarily to avoid sending large request bodies when the server might reject the request based on the headers alone. When a server receives a request with the Expect: 100-continue header, it should respond with either a 100 Continue status code or a final status code, depending on whether the request is acceptable or not.

Was this helpful?

Thanks for your feedback!