pub struct RequestHead { /* private fields */ }Expand description
A canonical, transport-independent HTTP request head.
Carries the method, request target, HTTP version, and headers from an HTTP request. Immutable after construction.
§Hyper independence
No Hyper type appears in this struct or its public API. Downstream code can inspect requests using only public eggserve types.
§Construction
Build through validated constructors or from the runtime adapter (Hyper → canonical conversion).
Implementations§
Source§impl RequestHead
impl RequestHead
Sourcepub fn new(
method: Method,
target: RequestTarget,
version: HttpVersion,
headers: HeaderBlock,
) -> Self
pub fn new( method: Method, target: RequestTarget, version: HttpVersion, headers: HeaderBlock, ) -> Self
Create a new request head.
Prefer using Self::try_from_hyper for converting from Hyper
requests. This constructor is for direct construction in tests or
downstream code that already has validated components.
Sourcepub fn target(&self) -> &RequestTarget
pub fn target(&self) -> &RequestTarget
Returns the request target.
Sourcepub fn version(&self) -> HttpVersion
pub fn version(&self) -> HttpVersion
Returns the HTTP version.
Sourcepub fn headers(&self) -> &HeaderBlock
pub fn headers(&self) -> &HeaderBlock
Returns the header block.
Sourcepub fn permits_static_resolution(&self) -> bool
pub fn permits_static_resolution(&self) -> bool
Returns true if the method permits static file resolution.
Sourcepub fn try_from_hyper<B>(req: &Request<B>) -> Result<Self, RequestHeadError>
pub fn try_from_hyper<B>(req: &Request<B>) -> Result<Self, RequestHeadError>
Convert a Hyper request into a canonical RequestHead.
Extracts method, URI, version, and headers from the Hyper request without consuming the body. The conversion is fallible and typed: malformed or unsupported input is rejected before handlers.
§Errors
Returns RequestHeadError if the request target, version, or
headers are invalid.
Trait Implementations§
Source§impl Clone for RequestHead
impl Clone for RequestHead
Source§fn clone(&self) -> RequestHead
fn clone(&self) -> RequestHead
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more