Skip to main content

Crate ephemeris_loopback

Crate ephemeris_loopback 

Source
Expand description

A throwaway HTTP/1.1 server on an ephemeral loopback port, shared by the tests of the forge crates and their consumers. This is a dev-only crate.

It answers canned responses and keeps every request it was sent, so a test can assert on the bytes the client put on the wire. It is hand written rather than taken from a crate such as wiremock: the whole server is one accept loop, and a mock HTTP crate would add a second HTTP stack, and the transitive versions that come with it, to a crate that deliberately vendors a small dependency set and runs clippy::cargo.

The accept loop runs on a dedicated background runtime rather than the caller’s own, so Server::start works the same from a #[test] and from a #[tokio::test].

StructsΒ§

Request
One request as it arrived on the wire.
Response
One canned response.
Server
A server listening on 127.0.0.1 with a port the kernel picked.

StaticsΒ§

INSTALLING πŸ”’
Serializes callers of install_tls_provider within this process.

FunctionsΒ§

background_runtime πŸ”’
A background tokio runtime shared by every server in this test binary.
find πŸ”’
install_tls_provider
Install the OpenSSL TLS provider for tests, keeping an existing provider.
read_more πŸ”’
read_request πŸ”’
write_response πŸ”’