[][src]Struct minreq::ResponseLazy

pub struct ResponseLazy {
    pub status_code: i32,
    pub reason_phrase: String,
    pub headers: HashMap<String, String>,
    // some fields omitted
}

An HTTP response, which is loaded lazily.

In comparison to Response, this is returned from send_lazy(), where as Response is returned from send().

In practice, "lazy loading" means that the bytes are only loaded as you iterate through them. The bytes are provided in the form of a Result<(u8, usize), minreq::Error>, as the reading operation can fail in various ways. The u8 is the actual byte that was read, and usize is how many bytes we are expecting to read in the future (including this byte). Note, however, that the usize can change, particularly when the Transfer-Encoding is chunked: then it will reflect how many bytes are left of the current chunk.

Example

// This is how the normal Response works behind the scenes, and
// how you might use ResponseLazy.
let response = minreq::get("http://httpbin.org/ip").send_lazy()?;
let mut vec = Vec::new();
for result in response {
    let (byte, length) = result?;
    vec.reserve(length);
    vec.push(byte);
}

Fields

status_code: i32

The status code of the response, eg. 404.

reason_phrase: String

The reason phrase of the response, eg. "Not Found".

headers: HashMap<String, String>

The headers of the response. The header field names (the keys) are all lowercase.

Trait Implementations

impl Iterator for ResponseLazy[src]

type Item = Result<(u8, usize), Error>

The type of the elements being iterated over.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.