Note: introduced in 0.7.0
.
The :expect
plugin enables sending the Expect: 100-continue
header on all requests that typically have a request body (POST, PATCH…).
httpx
already supported the flow when the user would pass the header manually, however, this plugin adds the following features on top of it:
Expect
header if the server responds with 417 Expectation Failed
.:expect_timeout
option (default: 2) if no 100 continue
response is received.You can set how long (in seconds) you want to wait for the 100 Continue
response before sending the body. This is similar to what cURL does in such cases.
When set, it means: the byte size threshold until which the Expect
header won’t be sent. This option is here if your requests are so small that using Expect
only adds latency, however, you’d like to enable it when uploading big files.
HTTPX.plugin(:expect, expect_timeout: 10).post(....
Next: Rate Limiter