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: MethodRead-only HTTP method used for canonicalization.
scheme: SchemeRead-only HTTP scheme used for canonicalization.
Read-only HTTP authority used for canonicalization.
path: StringRead-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: HeaderMapStaged HTTP headers committed by Self::apply.
Implementations§
Source§impl SigningRequest
impl SigningRequest
Sourcepub fn build(parts: &mut Parts) -> Result<Self>
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.
Sourcepub fn apply(self, parts: &mut Parts) -> Result<()>
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.
Sourcepub fn path_percent_decoded(&self) -> Cow<'_, str>
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.
Sourcepub fn query_size(&self) -> usize
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.
Sourcepub fn query_push(&mut self, key: impl Into<String>, value: impl Into<String>)
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.
Sourcepub fn query_append(&mut self, query: &str)
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.
Sourcepub fn query_to_vec_with_filter(
&self,
filter: impl Fn(&str) -> bool,
) -> Vec<(String, String)>
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.
Sourcepub fn query_to_string(
query: Vec<(String, String)>,
sep: &str,
join: &str,
) -> String
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"Sourcepub fn query_to_percent_decoded_string(
query: Vec<(String, String)>,
sep: &str,
join: &str,
) -> String
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"Sourcepub fn header_get_or_default(&self, key: &HeaderName) -> Result<&str>
pub fn header_get_or_default(&self, key: &HeaderName) -> Result<&str>
Get header value by name.
Returns empty string if header not found.
Sourcepub fn header_value_normalize(v: &mut HeaderValue)
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.
Sourcepub fn header_name_to_vec_sorted(&self) -> Vec<&str>
pub fn header_name_to_vec_sorted(&self) -> Vec<&str>
Get header names as sorted vector.