Practical technical guides / Core IT: networking (HTTP Expect 100-continue)

curl Waits Before Sending a Large Request Body: Expect 100-continue and the One Second Timeout

curl sends Expect 100-continue above 1 MiB and waits a second for an answer. Against a silent server every large upload paid it; answering or refusing early fixed it.

By Sandeep Belgavi · Published 2026-11-15

curl sends Expect 100-continue above 1 MiB and waits a second for an answer. Against a silent server every large upload paid it; answering or refusing early fixed it.

A second that appears only above one megabyte

Dinky maintains the upload endpoint that the scanning stations at Belgavi's Book Store use to send nightly stock photos and catalogue files. Small uploads finish in milliseconds. Uploads above about one megabyte take a little over a second each, regardless of network speed, and the latency graph has a step at exactly 1.0 seconds. Nothing in the server logs explains it: the server reads every body quickly once it arrives.

The cause is a polite HTTP/1.1 feature. Before sending a large request body, a client may send only the request headers with Expect: 100-continue and wait for the server to say either "continue" with an interim 100 Continue response, or "no" with a final status such as 413 or 401. The point is to avoid uploading megabytes that the server will reject on the headers alone. When the server, or anything in front of it, never answers the expectation, the client waits until its own timeout and then sends the body anyway. With curl and libcurl that timeout is one second by default.

What the specification asks of each side

RFC 9110, section 10.1.1, is specific. A client that waits for 100 Continue must send the expectation, and must not send one on a request without content. A client "is not required to wait for any specific length of time" and "SHOULD NOT wait for an indefinite period", because interim responses cannot pass through HTTP/1.0 intermediaries. On the server side, an origin server that receives an HTTP/1.1 request with the expectation must either send an immediate final status, if the method, target and headers are enough to decide, or send 100 Continue, and it "MUST NOT wait for the content before sending the 100 (Continue) response". A server that receives the expectation in an HTTP/1.0 request must ignore it.

So the one-second step means some hop is neither inviting nor refusing. The client's timeout is the fallback the specification expects, and the second it costs is the price of that hop's silence.

The curl documentation describes the client half. curl sends the header by default when a POST is known or suspected to be larger than one megabyte, and also for PUT. --expect100-timeout sets how long it waits, one second by default, and libcurl's equivalent is CURLOPT_EXPECT_100_TIMEOUT_MS, default 1000 milliseconds. Removing the header with -H "Expect:" turns the behaviour off.

Measuring it locally

The companion example starts three local servers built on Python's http.server and uploads to each with curl:

  • never answers. A handler that speaks HTTP/1.0. Python's server answers an expectation only when both the request and the server use HTTP/1.1, so this one stays silent and simply reads the body when it comes. It stands in for any hop that does not implement the expectation.
  • sends 100. An HTTP/1.1 handler. http.server calls handle_expect_100, which sends 100 Continue before the handler reads the body.
  • rejects early. An HTTP/1.1 handler whose handle_expect_100 checks Content-Length against a 1,500,000-byte limit and answers 413 without inviting the body. Bodies within the limit get 100 Continue.

I ran it on Windows 11 loopback with curl 8.9.0, and again with curl 8.22.0; both behaved the same. Time to first response byte, with curl 8.9.0:

ServerBodycurl optionTime to first byteStatus
never answers1,000 Bdefault0.024 s201
never answers1 MiB minus 1 bytedefault0.021 s201
never answers1 MiB plus 1 bytedefault1.031 s201
never answers2 MiBdefault1.013 s201
never answers2 MiB-H "Expect:"0.004 s201
never answers2 MiB--expect100-timeout 0.20.225 s201
sends 1002 MiBdefault0.002 s201
rejects early2 MiBdefault0.014 s413
rejects early2 MiB-H "Expect:"0.004 s413

The boundary is exact: 1,048,575 bytes went without the header, 1,048,577 bytes with it, and the silent server added one second to every request above the line. A server that answered 100 Continue removed the wait entirely. The early-rejecting server returned 413 without receiving a byte of the 2 MiB body. Without the header, the same server still returned 413, but only after reading all 2,097,152 bytes, which is exactly the waste the expectation exists to prevent.

The example also has a raw-socket client that sends only the headers and reports the first thing each server says: nothing within 0.3 seconds from the silent server, HTTP/1.1 100 Continue from the inviting one, and HTTP/1.1 413 Content Too Large from the rejecting one. That part needs no curl and is fully deterministic.

Where the silence usually comes from

The origin application is not the only suspect. Every hop that terminates HTTP/1.1 decides what to do with an expectation: load balancers, reverse proxies, API gateways, web application firewalls, service mesh sidecars and the HTTP server inside the application framework. Some answer 100 Continue on behalf of the backend, some forward the header, some strip it and some ignore it. A request can be fast against the application directly and slow through the gateway, or the other way round.

To find the hop, send the same large upload with curl's verbose output and look for HTTP/1.1 100 Continue before the final status, first against the public endpoint, then against each hop you can reach directly. The hop where the interim response disappears is the one to fix. A one-second plateau in timing histograms, visible only for large bodies, is the usual first clue.

Fixes, in order of preference

  1. Answer the expectation at the hop that owns the decision. If the server can reject on headers alone, for size, authentication or content type, it should do so immediately with the final status. Otherwise it should send 100 Continue without waiting for the body. In Python's http.server that means speaking HTTP/1.1 and, if you want early rejection, overriding handle_expect_100 as the example does; other servers and proxies have their own settings.
  2. Enforce the same limits after the body arrives. The rejecting server in the example checks the limit in both places, because a client is free not to send the expectation. Early rejection is an optimisation, never the only check.
  3. Tune the client if you cannot fix the server. For uploads to a hop you do not control, either remove the header (-H "Expect:", or setting the header to empty in libcurl) or lower the timeout. Removing it is right when the server never rejects on headers; lowering it keeps the benefit if the server sometimes answers.

Tradeoffs

The expectation trades a round trip for the chance to skip a wasted upload. On a fast, nearby link with a server that rarely rejects, the round trip costs more than it saves. On a slow or metered link, or with authentication that often fails, it saves real bandwidth and time. It is also the only clean way for a server to refuse a large body without either reading it or closing the connection mid-upload, which a client may report as a reset instead of the server's status.

Failure modes

Expectation on small bodies. A client configured to send the header on every upload pays the round trip even when the body would have fitted in the first packets, so for small bodies the wait is pure cost.

Proxies that answer on the backend's behalf. A proxy that sends 100 Continue immediately and then buffers the body defeats early rejection at the backend. That is allowed, and it is still worth knowing which hop does it.

HTTP/2 and HTTP/3. The expectation exists in both, but the costs differ because streams can be reset without closing the connection. This article measured HTTP/1.1 only.

Retries hide the step. A client library that retries slow uploads can turn a one-second wait into several, and the latency graph shows a blur instead of a step.

Verification

The companion example pins the raw-socket answers in expected.json. Its tests check those answers, that a small body is invited even by the rejecting server, and that nobody answers headers without an expectation before the body. When curl is available, six more tests run the timed probe and check timing classes with wide margins: no expectation at or below one mebibyte, about one second against the silent server above it, no wait when the header is removed or the server answers, a shorter wait with a shorter timeout, early rejection that never receives the body, and the full body read when the header is removed. Both curl recordings are in the example's recorded directory.

Primary references and authorship

Original explanation and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/expect_continue_probe. Views are my own and do not represent any employer, past or present.