Skip to main content

SigningRequest

Struct SigningRequest 

Source
pub struct SigningRequest {
    pub method: Method,
    pub scheme: Scheme,
    pub authority: Authority,
    pub path: String,
    pub query: Vec<(String, String)>,
    pub headers: HeaderMap,
}
Expand description

A service-local canonicalization view and signed-header staging area.

The method and URI-derived fields are read-only working values. They do not own the wire URI and must not be mutated to express signing output. The URI supplied to Self::build is already the final caller-provided representation; services derive canonical values locally and construct query authentication from the original URI.

Fields§

§method: Method

Read-only HTTP method used for canonicalization.

§scheme: Scheme

Read-only HTTP scheme used for canonicalization.

§authority: Authority

Read-only HTTP authority used for canonicalization.

§path: String

Read-only, percent-encoded wire path.

Services may derive a canonical path from this value, but must not decode it and write the result back to the request URI.

§query: Vec<(String, String)>

HTTP query parameters decoded once from the wire query for canonicalization.

Percent escapes are decoded once, literal + remains +, and duplicate order is retained. This working view does not own or rebuild the wire URI.

§headers: HeaderMap

Staged HTTP headers committed by Self::apply.

Implementations§

Source§

impl SigningRequest

Source

pub fn build(parts: &mut Parts) -> Result<Self>

Build a read-only request-target working view from http::request::Parts.

The URI path and query must already be percent-encoded for transport, and the URI must contain an authority. This method clones the URI-derived values and headers; the input request head remains unchanged on success or error.

Source

pub fn apply(self, parts: &mut Parts) -> Result<()>

Commit staged headers back to http::request::Parts.

In debug builds, this method verifies that the method, scheme, authority, path, and decoded query working view still match parts. A mismatch returns an error without changing parts. Release builds omit this implementation check.

On success, only headers are committed. This method never writes the method or URI. Query signers must construct their final URI from the original wire URI and assign it separately after all fallible signing work succeeds.

Source

pub fn path_percent_decoded(&self) -> Cow<'_, str>

Return the entire working path percent-decoded.

This is a canonicalization helper, not a wire URI builder. Decoding the entire path turns encoded slashes such as %2F into /; services where encoded slash is data must decode path segments separately.

Source

pub fn query_size(&self) -> usize

Return the combined key and value length of the decoded working query.

This is not the byte length of the wire query.

Source

pub fn query_push(&mut self, key: impl Into<String>, value: impl Into<String>)

Push a new query pair into the working query view.

This does not modify the wire URI. Self::apply rejects a modified request-target view in debug builds and ignores it in release builds. Query signers must construct their final URI from the original wire URI instead.

Source

pub fn query_append(&mut self, query: &str)

Push a query string into the working query view.

This does not modify the wire URI; see Self::query_push.

Source

pub fn query_to_vec_with_filter( &self, filter: impl Fn(&str) -> bool, ) -> Vec<(String, String)>

Clone working query pairs whose keys match a canonicalization filter.

Source

pub fn query_to_string( query: Vec<(String, String)>, sep: &str, join: &str, ) -> String

Convert sorted query pairs to a canonical string.

This helper does not produce or modify a wire URI.

[(a, b), (c, d)] => "a:b\nc:d"
Source

pub fn query_to_percent_decoded_string( query: Vec<(String, String)>, sep: &str, join: &str, ) -> String

Convert sorted query pairs to a string after percent-decoding each value.

Values from Self::query have already been decoded once. Passing them to this helper performs an additional decode and is only correct when a service protocol explicitly requires it. This helper does not produce a wire URI.

[(a, b), (c, d)] => "a:b\nc:d"
Source

pub fn header_get_or_default(&self, key: &HeaderName) -> Result<&str>

Get header value by name.

Returns empty string if header not found.

Source

pub fn header_value_normalize(v: &mut HeaderValue)

Normalize a header value for canonicalization.

Normalize a clone when the protocol does not require changing the wire header; mutating a value inside Self::headers changes the header committed by Self::apply.

Source

pub fn header_name_to_vec_sorted(&self) -> Vec<&str>

Get header names as sorted vector.

Source

pub fn header_to_vec_with_prefix(&self, prefix: &str) -> Vec<(String, String)>

Get header names with given prefix.

Source

pub fn header_to_string( headers: Vec<(String, String)>, sep: &str, join: &str, ) -> String

Convert sorted headers to string.

[(a, b), (c, d)] => "a:b\nc:d"

Trait Implementations§

Source§

impl Debug for SigningRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.