Expand description
An async HTTP/1.1 and HTTP/2 client over rustls, for the mirrors of a remote.
A caller builds a Fetcher from the mirrors, headers, credentials, proxy,
TLS configuration, retry limits, and deadlines of one remote. The fetcher
downloads files with GET and sends uploads with POST, PUT, or
DELETE. A response body streams in bounded chunks, so no object is held
whole in memory.
The Target of a request is a path under each mirror, a path with a
query string under each mirror, or an absolute URL. The fetcher sends a
path and a query as written, so the caller escapes them. A fetcher with a
RequestSigner sends a path in the form that
RequestSigner::request_path gives.
A failed fetch gives the status of the response. On request, it also gives the headers and a capped body of that response.
§Entry points
Fetcher::newbuilds a fetcher fromFetcherOptions.Fetcher::fetchsends aFetchRequestand returns aFetched.ErrorResponseholds the headers and the capped body of an unsuccessful response, if the request asks for them.Bodystreams a response body in bounded chunks.Fetcher::refetchingreturns aRefetch, which fetches a failed body again.Fetcher::uploadsends anUploadRequestand returns anUploaded.UploadBodygives an upload body whole or streams it from anUploadWriter.RequestSignersigns each attempt throughFetcherOptions::signer, and gives the form of each request path.Erroris the error of each fallible operation of the crate.
§Modules
gate: the priority admission gate that bounds concurrent work.
§Features
smol(default): thesmolbackend ofostrya-rt.tokio: thetokiobackend ofostrya-rt, with tokio I/O impls onBodyandUploadWriter.
§Examples
use futures_lite::AsyncReadExt;
use ostrya_fetch::{FetchRequest, Fetched, Fetcher, FetcherOptions};
let fetcher = Fetcher::new(FetcherOptions::new("https://example.com/repo")).await?;
if let Fetched::Body(mut body) = fetcher.fetch(FetchRequest::path("config")).await? {
let mut config = Vec::new();
body.read_to_end(&mut config).await?;
}Modules§
- gate
- A priority admission gate that bounds concurrent work.
Structs§
- Basic
Auth - The credentials of HTTP basic authentication.
- Bearer
Token - A token for
Authorization: Bearer. - Body
- The response body of a fetch or of an upload.
- Client
Identity - A client certificate and its private key, for TLS client authentication.
- Error
Response - The headers and the capped body of an unsuccessful response to a fetch.
- Fetch
Request - The request of one fetch.
- Fetcher
- An async HTTP client for one remote.
- Fetcher
Options - The options of a
Fetcher: the remote, the credentials, and the limits. - LowSpeed
- The lowest transfer rate that a fetch accepts.
- Refetch
- A fetch that starts again if its body fails in transit.
- Sign
Request - The parts of one attempt that a signer signs, as the request carries them.
- TlsOptions
- The TLS options of a fetcher.
- Upload
Body - The request body of an upload.
- Upload
Request - The request of one upload, which sends a body and gets a bounded response.
- Upload
Writer - The writing end of a streamed
UploadBody, fromUploadBody::channel. - Uploaded
- The answer to an upload: the status, the headers, and the response body.
- Validators
- The validators of a response, which make a later fetch conditional.
Enums§
- Error
- The error of each fallible operation of this crate.
- Fetched
- The result of a fetch.
- Priority
- The priority of a request that waits for admission to a
Fetcher. - Protocol
- The HTTP version of a response.
- Proxy
- The proxy through which a
Fetcherreaches each origin. - Sign
Payload - The body of a signed request.
- Target
- The target of a request.
- Trust
Roots - The trust setting that a fetcher verifies a server certificate with.
- Upload
Method - The method of an upload.
Traits§
- Request
Signer - A signer that adds the headers of a request signature to each attempt.
Functions§
- check_
base_ url - Checks that
urlis a base URL that a fetcher takes as a mirror. - check_
options - Makes each refusal of
Fetcher::newthat reads no file, in the order ofFetcher::new, with the same errors.