Skip to main content

Crate ostrya_fetch

Crate ostrya_fetch 

Source
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

§Modules

  • gate: the priority admission gate that bounds concurrent work.

§Features

  • smol (default): the smol backend of ostrya-rt.
  • tokio: the tokio backend of ostrya-rt, with tokio I/O impls on Body and UploadWriter.

§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§

BasicAuth
The credentials of HTTP basic authentication.
BearerToken
A token for Authorization: Bearer.
Body
The response body of a fetch or of an upload.
ClientIdentity
A client certificate and its private key, for TLS client authentication.
ErrorResponse
The headers and the capped body of an unsuccessful response to a fetch.
FetchRequest
The request of one fetch.
Fetcher
An async HTTP client for one remote.
FetcherOptions
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.
SignRequest
The parts of one attempt that a signer signs, as the request carries them.
TlsOptions
The TLS options of a fetcher.
UploadBody
The request body of an upload.
UploadRequest
The request of one upload, which sends a body and gets a bounded response.
UploadWriter
The writing end of a streamed UploadBody, from UploadBody::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 Fetcher reaches each origin.
SignPayload
The body of a signed request.
Target
The target of a request.
TrustRoots
The trust setting that a fetcher verifies a server certificate with.
UploadMethod
The method of an upload.

Traits§

RequestSigner
A signer that adds the headers of a request signature to each attempt.

Functions§

check_base_url
Checks that url is a base URL that a fetcher takes as a mirror.
check_options
Makes each refusal of Fetcher::new that reads no file, in the order of Fetcher::new, with the same errors.

Type Aliases§

Result
The result type of this crate, with Error as the error.