pub struct HttpsClientBuilder { /* private fields */ }client only.Expand description
Builder for HttpsClient.
Implementations§
Source§impl HttpsClientBuilder
impl HttpsClientBuilder
Sourcepub fn server_url(self, url: impl Into<String>) -> Self
pub fn server_url(self, url: impl Into<String>) -> Self
Base URL of the server, e.g. "https://server.example". The client
will POST to <server_url>/trust-tasks.
It must be https. A plain http URL is accepted when its host is
loopback (localhost, 127.0.0.0/8, [::1] — local servers and
tests), or elsewhere with Self::allow_insecure_http; a bearer
token is never sent to a non-loopback http URL.
Sourcepub fn server_vid(self, vid: impl Into<String>) -> Self
pub fn server_vid(self, vid: impl Into<String>) -> Self
VID of the server, used as the in-band recipient on outbound
documents and cross-checked with what the transport identifies as
the peer.
Sourcepub fn my_vid(self, vid: impl Into<String>) -> Self
pub fn my_vid(self, vid: impl Into<String>) -> Self
VID of this client, used as the in-band issuer.
Sourcepub fn my_token(self, token: impl Into<String>) -> Self
pub fn my_token(self, token: impl Into<String>) -> Self
Bearer token sent in Authorization: Bearer <token>. The server
resolves the token to a VID and uses that as the transport-
authenticated sender for §4.8.1 precedence.
Sourcepub fn strip_redundant_in_band(self, strip: bool) -> Self
pub fn strip_redundant_in_band(self, strip: bool) -> Self
If true, the client strips in-band issuer/recipient when
they match my_vid/server_vid respectively (SPEC §9.2 item 1).
Defaults to false: the safe behavior is to leave the in-band
members in place so the document remains self-contained at rest.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
End-to-end request timeout. Defaults to DEFAULT_TIMEOUT.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Connection-establishment timeout. Defaults to
DEFAULT_CONNECT_TIMEOUT.
Sourcepub fn max_response_bytes(self, limit: usize) -> Self
pub fn max_response_bytes(self, limit: usize) -> Self
The largest response body the client reads, in bytes. A larger one
fails with ClientError::ResponseTooLarge as soon as it is
detected, without buffering the rest. Defaults to
DEFAULT_MAX_RESPONSE_BYTES.
Sourcepub fn allow_insecure_http(self, allow: bool) -> Self
pub fn allow_insecure_http(self, allow: bool) -> Self
Accept a plain http Self::server_url whose host is not loopback.
The document then crosses the network unencrypted. Even so, a
configured Self::my_token is refused over it: Self::build
fails rather than send the token in the clear.
Sourcepub fn follow_redirects(self, follow: bool) -> Self
pub fn follow_redirects(self, follow: bool) -> Self
Follow redirects to the same origin (scheme, host and port), at most
five. Off by default: a 3xx is returned as
ClientError::HttpStatus, so a signed document is never re-posted
to a URL other than the one configured. A redirect to another origin
is never followed.
Sourcepub fn with_response_verifier<V>(self, verifier: V) -> Self
pub fn with_response_verifier<V>(self, verifier: V) -> Self
Verify the proof on every response document.
Off by default, and off is not the same as safe: with no verifier the
client checks nothing cryptographic about what came back. The
correlation checks HttpsClient::send performs — threadId,
type, issuer, recipient — bind a response to its request, but
they are all assertions by whoever answered the socket.
Configuring a verifier expresses “I require signed responses”: a
proofless response is then rejected with
ClientError::ResponseProofMissing rather than quietly accepted,
because a downgrade that goes unnoticed is worth no more than no
verification at all. Note the bundled HttpsServer
does not sign its responses, so this is for peers that do.
The proof is verified over the response body exactly as received, never a re-serialisation of it, so a peer’s own spelling of a timestamp or member order does not break a valid signature.
Error responses are held to it too. A trust-task-error is
returned as ClientError::TrustTaskError only when its proof
verifies and its issuer / recipient match the configured VIDs, as a
success response’s must. Anything else — an unsigned error, a bad
proof, an error from another party — is returned as
ClientError::UnverifiedErrorResponse: the body is kept for logging,
but nothing about it is attested, and it must not be read as the
server’s answer.
Sourcepub fn build(self) -> Result<HttpsClient, ClientError>
pub fn build(self) -> Result<HttpsClient, ClientError>
Build the HttpsClient or return a configuration error.