Struct thhp::Request

source ·
pub struct Request<'headers, 'buffer: 'headers> {
    pub method: &'buffer str,
    pub target: &'buffer str,
    pub minor_version: u8,
    pub headers: &'headers [HeaderField<'buffer>],
}
Expand description

A parsed request.

Example

let buf = b"GET / HTTP/1.1\r\nHost: example.com";
let mut headers = Vec::<thhp::HeaderField>::with_capacity(16);
match thhp::Request::parse(buf, &mut headers) {
    Ok(thhp::Complete((ref req, len))) => {
        // Use request.
    },
    Ok(thhp::Incomplete) => {
        // Read more and parse again.
    },
    Err(err) => {
        // Handle error.
    }
}

Fields§

§method: &'buffer str

The request method.

§target: &'buffer str

The request target.

§minor_version: u8

The http minor version.

§headers: &'headers [HeaderField<'buffer>]

The request header fields.

Implementations§

Parse the buffer as http request.

Trait Implementations§

Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.