Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required method
    fn get_text<'life0, 'life1, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<(StatusCode, Bytes), SpiderError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

A simple HTTP client trait for fetching web content.

Required Methods§

Source

fn get_text<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(StatusCode, Bytes), SpiderError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Fetches the content of a URL as text.

§Errors

Returns an error when the request fails, times out, or the response body cannot be read.

Implementations on Foreign Types§

Source§

impl HttpClient for Client

Source§

fn get_text<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(StatusCode, Bytes), SpiderError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Client: 'async_trait,

Implementors§