Skip to main content

ParsedH2Message

Struct ParsedH2Message 

Source
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: Option<String>

: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: StreamId

HTTP/2 stream identifier

§header_size: usize

Total decoded header size in bytes

§body: Vec<u8>

Accumulated body from DATA frames

§first_frame_timestamp_ns: TimestampNs

Timestamp when first frame for this stream was received

§end_stream_timestamp_ns: TimestampNs

Timestamp when stream completed (END_STREAM received)

Implementations§

Source§

impl ParsedH2Message

Source

pub fn is_request(&self) -> bool

Returns true if this message is a request (has :method pseudo-header)

Source

pub fn is_response(&self) -> bool

Returns true if this message is a response (has :status pseudo-header)

Source

pub fn http_method(&self) -> Option<Method>

Convert :method pseudo-header to http::Method

Source

pub fn http_uri(&self) -> Option<Uri>

Convert :path pseudo-header to http::Uri (defaults to “/” if missing)

Source

pub fn http_status(&self) -> Option<StatusCode>

Convert :status pseudo-header to http::StatusCode

Source

pub fn http_headers(&self) -> HeaderMap

Convert headers to http::HeaderMap, including :authority as Host header

Source

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).

Source

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).

Source

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).

Source

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

Source§

fn clone(&self) -> ParsedH2Message

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParsedH2Message

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more