pub struct ParsedH2Message {
pub method: Option<String>,
pub path: Option<String>,
pub authority: Option<String>,
pub scheme: Option<String>,
pub status: Option<u16>,
pub headers: Vec<(String, String)>,
pub stream_id: StreamId,
pub header_size: usize,
pub body: Vec<u8>,
pub first_frame_timestamp_ns: TimestampNs,
pub end_stream_timestamp_ns: TimestampNs,
}Expand description
A fully parsed HTTP/2 message extracted from a completed stream.
Contains pseudo-headers (:method, :path, :status, etc.), regular
headers, accumulated body data, and timing information. Use
is_request() / is_response()
to classify, or the to_http_* / into_http_* helpers to convert into
HttpRequest / HttpResponse.
Fields§
§method: Option<String>:method pseudo-header (present for requests)
path: Option<String>:path pseudo-header (present for requests)
:authority pseudo-header (present for requests, mapped to Host)
scheme: Option<String>:scheme pseudo-header (present for requests)
status: Option<u16>:status pseudo-header (present for responses)
headers: Vec<(String, String)>Decoded headers (both pseudo and regular, in wire order)
stream_id: StreamIdHTTP/2 stream identifier
header_size: usizeTotal decoded header size in bytes
body: Vec<u8>Accumulated body from DATA frames
first_frame_timestamp_ns: TimestampNsTimestamp when first frame for this stream was received
end_stream_timestamp_ns: TimestampNsTimestamp when stream completed (END_STREAM received)
Implementations§
Source§impl ParsedH2Message
impl ParsedH2Message
Sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
Returns true if this message is a request (has :method pseudo-header)
Sourcepub fn is_response(&self) -> bool
pub fn is_response(&self) -> bool
Returns true if this message is a response (has :status pseudo-header)
Sourcepub fn http_method(&self) -> Option<Method>
pub fn http_method(&self) -> Option<Method>
Convert :method pseudo-header to http::Method
Sourcepub fn http_uri(&self) -> Option<Uri>
pub fn http_uri(&self) -> Option<Uri>
Convert :path pseudo-header to http::Uri (defaults to “/” if missing)
Sourcepub fn http_status(&self) -> Option<StatusCode>
pub fn http_status(&self) -> Option<StatusCode>
Convert :status pseudo-header to http::StatusCode
Sourcepub fn http_headers(&self) -> HeaderMap
pub fn http_headers(&self) -> HeaderMap
Convert headers to http::HeaderMap, including :authority as Host header
Sourcepub fn to_http_request(&self) -> Option<HttpRequest>
pub fn to_http_request(&self) -> Option<HttpRequest>
Convert this HTTP/2 message to an HttpRequest
Returns None if this is not a valid request (missing :method or :path). Uses end_stream_timestamp_ns as the request timestamp (when request was fully sent).
Sourcepub fn to_http_response(&self) -> Option<HttpResponse>
pub fn to_http_response(&self) -> Option<HttpResponse>
Convert this HTTP/2 message to an HttpResponse
Returns None if this is not a valid response (missing :status). Uses first_frame_timestamp_ns as the response timestamp (when response started arriving).
Sourcepub fn into_http_request(self) -> Option<HttpRequest>
pub fn into_http_request(self) -> Option<HttpRequest>
Consume this message and convert to an HttpRequest (zero-copy for body).
Returns None if this is not a valid request (missing :method or :path).
Sourcepub fn into_http_response(self) -> Option<HttpResponse>
pub fn into_http_response(self) -> Option<HttpResponse>
Consume this message and convert to an HttpResponse (zero-copy for body).
Returns None if this is not a valid response (missing :status).
Trait Implementations§
Source§impl Clone for ParsedH2Message
impl Clone for ParsedH2Message
Source§fn clone(&self) -> ParsedH2Message
fn clone(&self) -> ParsedH2Message
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more