pub trait RequestSigner:
Send
+ Sync
+ Debug {
// Required method
fn sign(&self, request: &SignRequest<'_>) -> Result<Vec<(String, String)>>;
// Provided method
fn request_path<'a>(&self, path: &'a str) -> Result<Cow<'a, str>> { ... }
}Expand description
A signer that adds the headers of a request signature to each attempt.
FetcherOptions::signer holds the signer of a fetcher. The fetcher calls
sign once for each request that it sends to the
origin that the route names. This includes each retry, each round, and
each redirect hop at that origin. The call occurs after the fetcher takes
the connection, so a signature with a date is fresh when the request
leaves. An upload over a pooled HTTP/1.1 connection that the server closed
continues over a new connection, and the fetcher calls the signer again.
A redirect hop at another origin gets no signature. No later hop of that attempt gets one, also a hop back to the named origin.
The fetcher calls the signer on the task of the request. A signer that
hashes a body given whole does that work on the task, on each call. A
caller with a large body gives the SHA-256 of the body with
UploadBody::bytes_with_sha256, so that the signer gets
SignPayload::Sha256 and hashes no byte of the body.
The path of a Target::Path or a Target::PathQuery goes through
request_path before the fetcher adds it
to the base path of a mirror. So a signer that signs a canonical form of
the path gets a request that carries that form. A Target::Url goes on
the wire as written.
The Debug output of a signer must show no secret, because the
Debug output of FetcherOptions includes it.
Required Methods§
Sourcefn sign(&self, request: &SignRequest<'_>) -> Result<Vec<(String, String)>>
fn sign(&self, request: &SignRequest<'_>) -> Result<Vec<(String, String)>>
Returns the headers that sign request. Each one replaces a header of
the same name.
The fetcher refuses a returned header as it refuses a request header:
an invalid name or value, a Host header, and a header that the
connection layer sets. Each returned value is marked sensitive, so an
HTTP/2 connection never adds it to its header compression table. Two
returned headers of one name both go on the wire.
§Errors
The fetcher passes an error of this method through unchanged, and the
request ends with it. The request sends nothing for the attempt, and
the fetcher tries no other destination and no other round. An error on
a redirect hop of an upload ends the upload with
Error::UploadInterrupted, because the first hop sent the request.
Usually, the error is Error::Fetch.
Provided Methods§
Sourcefn request_path<'a>(&self, path: &'a str) -> Result<Cow<'a, str>>
fn request_path<'a>(&self, path: &'a str) -> Result<Cow<'a, str>>
Returns path, the path of a Target::Path or a
Target::PathQuery, in the form that the request carries.
The fetcher calls this method once for each fetch and each upload
with a path target, before admission. It adds the result to the base
path of each mirror, in place of path. The fetcher does not call it
for a Target::Url, or for the query of a Target::PathQuery.
The default returns path unchanged. A signer whose signature covers
a canonical form of the path returns that form, so the request
carries the bytes that the signature covers.
§Errors
The fetcher passes an error of this method through unchanged, and the
request ends with it before admission. Usually, the error is
Error::Fetch.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".