pub async fn send(
request: &Request,
client: &HttpClient,
config: &Config,
) -> Result<Response, SendraError>Expand description
Send request under config and collect the full response.
The elapsed time covers connect, send and body read — i.e. what a user waits for, not just time-to-first-byte.
config is a parameter rather than something resolved in here, and is not
optional, so that a caller cannot send a request without deciding what
configuration applies to it. Callers with nothing to apply pass
Config::default, which is the same defaults resolution falls back to. It
contributes one thing here — default headers, merged by Config::apply
with the request winning ties. The other thing it decides, the timeout, was
applied when client was built; see build_client.
client is borrowed rather than built here so that a run sending more than
one request sends them all down the same connection pool. See
build_client for what that is worth and where the client should come
from.
This is the whole pipeline in one call, for a caller that has no reason to
step between the two halves. A caller that does — one running a
pre_request script, which by definition is the last thing to touch the
request — applies the config itself and calls send_prepared. That is the
only reason the seam exists; see there.