Struct thhp::Response

source ·
pub struct Response<'headers, 'buffer: 'headers> {
    pub minor_version: u8,
    pub status: u16,
    pub reason: &'buffer str,
    pub headers: &'headers [HeaderField<'buffer>],
}
Expand description

A parsed response.

Example

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

Fields§

§minor_version: u8

The http minor version.

§status: u16

The status code.

§reason: &'buffer str

The reason phrase

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

The response header fields.

Implementations§

Parse the buffer as http response.

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.