Skip to content

http

Structs

  • HttpOrigin - A scheme, host, and optional port, without a path, query, fragment, or
  • HttpUrl - An absolute HTTP(S) URL with a host and any path, without a query,

Enums

Functions

  • host_is_this_machine - Returns whether a URI host names this machine.
  • is_loopback - Returns whether url’s host is localhost, an IPv4 loopback address, or the

Traits


Enum

Allows HTTP or HTTPS on any host.

Use this only where another layer, such as an egress policy, decides whether plain HTTP may be used.

Traits: Eq, Copy

Trait Implementations:

  • SchemePolicy
    • fn check(scheme: &str, _host: &Host<&str>) -> Result<(), HttpUrlError>
  • Hash
    • fn hash<__H>(self: &Self, state: & mut __H)
  • PartialEq
    • fn eq(self: &Self, other: &Self) -> bool
  • Clone
    • fn clone(self: &Self) -> Self
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Struct

A scheme, host, and optional port, without a path, query, fragment, or credentials.

The canonical serialization, used by [fmt::Display] and [Serialize], is the ASCII origin serialization: a lowercase host, no default port, and no trailing slash, such as https://firma.example:8443. Parsing accepts any equivalent spelling, such as https://Firma.Example:443/.

Generic Parameters:

  • P

Methods:

  • fn new(url: Url) -> Result<Self, HttpUrlError> - Validates url as an origin under the scheme policy P.
  • fn as_url(self: &Self) -> &Url - Returns the origin as a URL whose path is /.

Traits: Eq

Trait Implementations:

  • Deserialize
    • fn deserialize<D>(deserializer: D) -> Result<Self, <D as >::Error>
  • Serialize
    • fn serialize<S>(self: &Self, serializer: S) -> Result<<S as >::Ok, <S as >::Error>
  • FromStr
    • fn from_str(value: &str) -> Result<Self, <Self as >::Err>
  • Display
    • fn fmt(self: &Self, formatter: & mut fmt::Formatter) -> fmt::Result
  • From
    • fn from(origin: HttpOrigin<Https>) -> Self
  • Hash
    • fn hash<__H>(self: &Self, state: & mut __H)
  • PartialEq
    • fn eq(self: &Self, other: &Self) -> bool
  • Clone
    • fn clone(self: &Self) -> Self
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Struct

An absolute HTTP(S) URL with a host and any path, without a query, fragment, or credentials.

The URL is kept exactly as written, so a value whose path identity matters, such as an OIDC issuer or a redirect URI, round-trips unchanged. To derive a URL beneath it, use [HttpUrl::join_path] rather than [Url::join]: Url::join replaces the last path segment unless the path ends with /.

Generic Parameters:

  • P

Methods:

  • fn new(url: Url) -> Result<Self, HttpUrlError> - Validates url under the scheme policy P.
  • fn as_url(self: &Self) -> &Url - Returns the URL as written.
  • fn join_path(self: &Self, relative: &str) -> Url - Returns this URL with relative appended beneath its path, treating

Traits: Eq

Trait Implementations:

  • Deserialize
    • fn deserialize<D>(deserializer: D) -> Result<Self, <D as >::Error>
  • Serialize
    • fn serialize<S>(self: &Self, serializer: S) -> Result<<S as >::Ok, <S as >::Error>
  • FromStr
    • fn from_str(value: &str) -> Result<Self, <Self as >::Err>
  • Display
    • fn fmt(self: &Self, formatter: & mut fmt::Formatter) -> fmt::Result
  • Hash
    • fn hash<__H>(self: &Self, state: & mut __H)
  • PartialEq
    • fn eq(self: &Self, other: &Self) -> bool
  • Clone
    • fn clone(self: &Self) -> Self
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Enum

Why a URL is not a valid [HttpOrigin] or [HttpUrl].

Variants:

  • MissingHost - The URL does not identify a host.
  • Credentials - The URL includes a user name or password.
  • Path - An origin includes a path other than /.
  • Query - The URL includes a query, even an empty one.
  • Fragment - The URL includes a fragment, even an empty one.
  • UnsupportedScheme - The scheme is neither HTTP nor HTTPS.
  • RequiresHttps - The URL uses HTTP where only HTTPS is allowed.
  • HttpRequiresLoopback - The URL uses HTTP with a host that is not loopback.

Traits: Error, Eq, Copy

Trait Implementations:

  • Display
    • fn fmt(self: &Self, __formatter: & mut ::core::fmt::Formatter) -> ::core::fmt::Result
  • PartialEq
    • fn eq(self: &Self, other: &Self) -> bool
  • Clone
    • fn clone(self: &Self) -> Self
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Enum

Requires HTTPS.

Traits: Eq, Copy

Trait Implementations:

  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result
  • SchemePolicy
    • fn check(scheme: &str, _host: &Host<&str>) -> Result<(), HttpUrlError>
  • Hash
    • fn hash<__H>(self: &Self, state: & mut __H)
  • PartialEq
    • fn eq(self: &Self, other: &Self) -> bool
  • Clone
    • fn clone(self: &Self) -> Self

firma_config_utils::http::HttpsOrLoopbackHttp

Section titled “firma_config_utils::http::HttpsOrLoopbackHttp”

Enum

Requires HTTPS, except that HTTP is allowed when the host is localhost, an IPv4 loopback address, or the IPv6 loopback address.

Traits: Eq, Copy

Trait Implementations:

  • SchemePolicy
    • fn check(scheme: &str, host: &Host<&str>) -> Result<(), HttpUrlError>
  • Hash
    • fn hash<__H>(self: &Self, state: & mut __H)
  • PartialEq
    • fn eq(self: &Self, other: &Self) -> bool
  • Clone
    • fn clone(self: &Self) -> Self
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

firma_config_utils::http::ParseHttpUrlError

Section titled “firma_config_utils::http::ParseHttpUrlError”

Enum

Why text does not parse as an [HttpOrigin] or [HttpUrl].

Variants:

  • Malformed(url::ParseError) - The text is not an absolute URL.
  • Invalid(HttpUrlError) - The URL does not have the required shape or scheme.

Traits: Eq

Trait Implementations:

  • PartialEq
    • fn eq(self: &Self, other: &Self) -> bool
  • Clone
    • fn clone(self: &Self) -> Self
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result
  • From
    • fn from(source: HttpUrlError) -> Self
  • From
    • fn from(source: url::ParseError) -> Self
  • Display
    • fn fmt(self: &Self, __formatter: & mut ::core::fmt::Formatter) -> ::core::fmt::Result
  • Error
    • fn source(self: &Self) -> ::core::option::Option<&dyn ::thiserror::__private21::Error>

Trait

The schemes a validated URL may use.

This trait is sealed; the policies are [Https], [HttpsOrLoopbackHttp], and [HttpOrHttps].

Methods:

  • check: Checks the scheme of a URL whose host is already known to be present.

firma_config_utils::http::host_is_this_machine

Section titled “firma_config_utils::http::host_is_this_machine”

Function

Returns whether a URI host names this machine.

That is localhost or a loopback address, including an IPv4 loopback address written as IPv4-mapped IPv6; an IPv6 literal may be bracketed and a name may carry a trailing dot.

This is where a server certificate would come from a local CA rather than a public one. It is broader than [is_loopback], which decides where plain HTTP is allowed and accepts neither an IPv4-mapped address nor a trailing dot.

fn host_is_this_machine(host: &str) -> bool

Function

Returns whether url’s host is localhost, an IPv4 loopback address, or the IPv6 loopback address, the hosts [HttpsOrLoopbackHttp] allows over HTTP.

fn is_loopback(url: &url::Url) -> bool