pub struct RequestHead {
pub method: Method,
pub target: String,
pub headers: HeaderMap,
pub raw_headers: Option<Vec<(String, String)>>,
}Expand description
A request head: method, origin-form target and headers.
The body is passed separately to crate::write_request so the caller
controls its length; a Content-Length header is written for a present body
and never for an absent one.
Fields§
§method: Method§target: StringOrigin-form target (/v1/chat/completions); the authority lives in the
connection, not the message.
headers: HeaderMap§raw_headers: Option<Vec<(String, String)>>Explicit raw wire headers preserving caller-defined casing and order.
When Some, crate::write_request serializes these exact bytes
instead of lowercasing through http::HeaderMap.
Implementations§
Source§impl RequestHead
impl RequestHead
pub fn new(method: Method, target: impl Into<String>) -> Self
Sourcepub fn with_header(self, name: impl AsRef<str>, value: impl AsRef<str>) -> Self
pub fn with_header(self, name: impl AsRef<str>, value: impl AsRef<str>) -> Self
Insert a header. expect-free: an invalid name or value is a programming
error in the caller’s own literal, and is reported as false rather than
panicking.
Sourcepub fn with_raw_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_raw_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Append a raw header preserving caller’s exact name casing and duplicates.
This directly addresses HTTP-layer fingerprinting (JA4H) and WAF/DPI evasion:
wire casing (e.g. User-Agent, Host, Sec-CH-UA) and multi-value
repetition (e.g. repeated Cookie or Set-Cookie) are emitted byte-for-byte.