pub struct FetchRequest<'a> {
pub target: Target<'a>,
pub priority: Priority,
pub validators: Option<&'a Validators>,
pub max_size: Option<u64>,
pub headers: &'a [(String, String)],
pub basic_auth: Option<&'a BasicAuth>,
pub allow_cleartext_credentials: bool,
}Expand description
Fields§
§target: Target<'a>The target: a path under the base URL of each mirror, the same with a query string, or an absolute URL.
The fetcher adds a path to the base path as written, so the path carries
the escapes that the server expects. A path holds no ? and no #,
because neither is part of a path. Either one fails the fetch before
admission.
The fetcher adds ? and the query of Target::PathQuery after the
path, as written, so the query carries the escapes that the server
expects. A query holds no #, because a # starts a fragment. A #
fails the fetch before admission.
The fetcher sends the query string of a URL as written. A fragment in a URL fails the fetch, because no request sends a fragment. A character that a request target cannot hold fails the fetch when the fetcher assembles the URL.
priority: PriorityThe place of the request in the queue when the fetcher is at its limit.
validators: Option<&'a Validators>The validators of a previous fetch.
If the server reports that the copy is still current, the fetch gives
Fetched::NotModified.
max_size: Option<u64>The largest response body, in bytes, that the fetch accepts.
A larger Content-Length fails the fetch with Error::FetchTooLarge.
If a body grows past the cap while it streams, the read fails with
io::ErrorKind::FileTooLarge. The
fetcher compares the cap with the response that answers, and does not
measure an intermediate redirect response.
headers: &'a [(String, String)]Headers merged over the headers of the fetcher.
An entry replaces a fetcher header of the same name. Names compare as
HeaderName, so the comparison ignores case. Two entries of one name
both go on the wire. An invalid name or value fails the fetch before
admission.
The fetcher sets User-Agent and Accept-Encoding: identity, and an
entry of one of these names replaces the value. An entry can ask for a
content coding. A response that declares a coding fails with
Error::ContentEncoded, whichever layer asked for it.
A Host entry fails the fetch, because the header comes from the URL. A
header that the connection layer sets fails at both layers: a framing
name or a hop-by-hop name. The connection owns the framing of a request
and the state of its connection. A value of the caller puts the wire and
the connection pool out of step.
§Authorization
The request carries the Authorization header of the first of these
that is set:
FetchRequest::basic_auth- an
Authorizationentry in these headers FetcherOptions::basic_authorFetcherOptions::bearer_token- an
Authorizationentry inFetcherOptions::headers.
Credentials beside an Authorization header in one layer give two
answers to one question. Fetcher::new refuses them on the fetcher,
and the fetch refuses them on a request.
basic_auth: Option<&'a BasicAuth>Credentials that replace the credentials of the fetcher for this request.
These set the Authorization header, so an Authorization entry in
headers beside them fails the fetch.
The fetcher encodes the header value for each request. A caller that
sends one credential over many requests can encode the Authorization
value once and set it in headers. That entry
replaces the credential of the fetcher for the request in the same way.
allow_cleartext_credentials: boolThe permission for a credential to reach a cleartext origin.
If this is false and the merged headers carry a credential, the fetch
fails if a destination that it can reach is http. The merged headers
include the credentials of the fetcher. The check of Fetcher::new on
the mirror list applies whatever this value is. The default is false.
FetcherOptions::allow_cleartext_credentials lifts this refusal for
each request of the fetcher.
A redirect hop never carries a credential to a cleartext origin of its
own. The fetcher removes the credential for a hop at another origin, and
refuses a hop from https to http. Fetcher::fetch states the
redirect rules.
§Cleartext credentials
The fetcher withholds a credential from no destination that a route
names. So it refuses a credential and a cleartext destination together.
The credentials are basic_auth, and an
Authorization, Proxy-Authorization, or Cookie entry in the merged
headers. FetcherOptions::basic_auth and
FetcherOptions::bearer_token are Authorization entries in the
merged headers.
If a fetch carries a credential and a destination that it can reach is
http, the fetch fails before admission with Error::Fetch. The
message names that origin. The other choice is to withhold the
credential from that one destination. That choice turns a configuration
mistake into a 401 that names nothing.
Implementations§
Source§impl<'a> FetchRequest<'a>
impl<'a> FetchRequest<'a>
Sourcepub fn path(path: &'a str) -> FetchRequest<'a>
pub fn path(path: &'a str) -> FetchRequest<'a>
Creates a request for path under each mirror.
The request has normal priority, no validators, and no size cap. It carries the headers and the credentials of the fetcher.
Sourcepub fn path_query(path: &'a str, query: &'a str) -> FetchRequest<'a>
pub fn path_query(path: &'a str, query: &'a str) -> FetchRequest<'a>
Creates a request for path with the query string query under each
mirror.
The query has no leading ?. The request has normal priority, no
validators, and no size cap. It carries the headers and the
credentials of the fetcher.
Sourcepub fn url(url: &'a str) -> FetchRequest<'a>
pub fn url(url: &'a str) -> FetchRequest<'a>
Creates a request for the absolute URL url.
The request has normal priority, no validators, and no size cap. It carries the headers and the credentials of the fetcher.