The :expect
plugin enables sending the expect: 100-continue
header on all requests that contain 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 (similar to what curl
does).You can set how long (in seconds) you want to wait for the 100 Continue
response before sending the body.
When set, it means: the byte size threshold until which the expect: 100-continue
header won’t be sent. This option is here if some requests are so small that using expect: 100-continue
only generates needless round-trips, but you’d still like to enable it when uploading files.
HTTPX.plugin(:expect, expect_timeout: 10).post("https://example.com")
Next: Rate Limiter