Skip to main content

Crate didbot_http

Crate didbot_http 

Source
Expand description

One constructor for every outbound reqwest client this workspace builds. A client with no timeout waits forever on a black-holed route.

The workspace’s clippy.toml disallows reqwest’s own constructors, so a client built anywhere else fails the lint. A caller that needs another total deadline, such as a held poll, sets it on the builder this returns; the connect timeout stays.

read_bounded is the other half: a timeout bounds how long a response may take, not how much of it a caller will hold in memory. .json() on an unbounded body is a memory sink against any server this process does not run – an operator’s PDS, or whoever a DID document points at.

REFUSED_BLOCKS is the third: which addresses an outbound fetch may reach at all. A URL named by a stranger, or by a document this server just fetched, is aimed by somebody else; resolve_public and pinned_client are how it stays aimed at the public internet.

EXTRA_CA_CERTS is the fourth: which authorities a client here trusts on top of the ones it is built with.

doh is DNS over HTTPS, one GET through a pinned client, for the records a stub resolver has no API for.

lookup_host is how every client here resolves a name: RFC 6761’s localhost names go to loopback, and the rest go to the system.

Modules§

address 🔒
The one list of address blocks this workspace will not fetch from, and the resolution that enforces it.
doh
DNS over HTTPS, for the records a stub resolver has no API for: a zone’s nameservers, a handle’s TXT record, a lexicon authority’s TXT record.
resolve 🔒
Name resolution for every client built here.
test_support
A server that has stopped answering, for tests of a client’s timeouts.

Enums§

AddressError
Why an address check did not let a fetch proceed.
PrivateAddresses
Whether a caller accepts a host that resolves into REFUSED_BLOCKS.
ReadBoundedError
Why read_bounded did not return a body.

Constants§

DEFAULT_CONNECT_TIMEOUT
How long establishing a connection – DNS, then the TCP and TLS handshake – may take, independent of DEFAULT_TIMEOUT.
DEFAULT_TIMEOUT
The total deadline – connect, send the request, and read the response – for a request to a server this deployment does not run: an operator’s PDS, a relay, the ACME directory, a client’s own metadata document.
EXTRA_CA_CERTS
The environment variable naming a PEM file of certificate authorities every client built here trusts, on top of the ones it is built with.
MAX_JSON_BODY
The most of one response body this workspace will hold in memory to read it, when the response comes from a server nothing here operates.
REFUSED_BLOCKS
The address blocks an outbound fetch is refused for.

Statics§

PROCESS_ROOTS 🔒
Authorities a test added for this process; see test_support::trust. Empty in anything that is not a test, and read on every build so a test that adds one before its first request is enough.

Functions§

blocking_builder
builder’s two timeouts on a [reqwest::blocking::ClientBuilder], for a caller with no async runtime to drive the async client on.
body_text
The body of a bounded read, as text.
builder
A [reqwest::ClientBuilder] pre-configured with DEFAULT_CONNECT_TIMEOUT and DEFAULT_TIMEOUT, for a caller that needs to layer something else on top – a redirect policy, a user agent – before building.
client
The default outbound client: builder, built.
extra_root_certificates 🔒
The authorities EXTRA_CA_CERTS names, or nothing if it is unset.
is_localhost_name
Whether name is localhost or a name under it.
is_loopback
Whether url names this machine and nowhere else.
is_public_address
Whether an outbound fetch may reach address: true unless it falls in REFUSED_BLOCKS.
lookup_host
Every address name answers to at port: loopback for a localhost name, and the system’s answer for any other.
pinned_client
A client for url: its host resolved once through resolve_public, pinned to what it resolved to so the connection cannot land elsewhere, and following no redirect, which would land it elsewhere all the same.
read_bounded
Reads at most max_bytes of response’s body.
read_bounded_blocking
read_bounded, for a caller with no async runtime.
refuse_private_host
resolve_public for a caller holding its URL as text, when nothing past the refusal is wanted.
resolve_public
Every address url’s host answers to, refused unless every one of them is public.