Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required methods
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_with_query<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        query: &'life2 [(&'life3 str, &'life4 str)],
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn post<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        body: Vec<u8>,
        content_type: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn post_form<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        form: &'life2 [(&'life3 str, &'life4 str)],
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;

    // Provided methods
    fn get_with_cookies<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        cookies: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn post_form_with_cookies<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        form: &'life2 [(&'life3 str, &'life4 str)],
        cookies: &'life5 str,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait { ... }
}
Expand description

HTTP client trait for making web requests.

This trait abstracts HTTP operations, enabling mock implementations for unit testing without actual network calls.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform a GET request.

§Arguments
  • url - The URL to request
Source

fn get_with_query<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, url: &'life1 str, query: &'life2 [(&'life3 str, &'life4 str)], ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Perform a GET request with query parameters.

§Arguments
  • url - The base URL
  • query - Query parameters as key-value pairs
Source

fn post<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, url: &'life1 str, body: Vec<u8>, content_type: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Perform a POST request with a body.

§Arguments
  • url - The URL to post to
  • body - The request body
  • content_type - The content type header value
Source

fn post_form<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, url: &'life1 str, form: &'life2 [(&'life3 str, &'life4 str)], ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Perform a POST request with form data.

§Arguments
  • url - The URL to post to
  • form - Form fields as key-value pairs

Provided Methods§

Source

fn get_with_cookies<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, url: &'life1 str, cookies: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Perform a GET request carrying a raw Cookie header value.

Default implementation delegates to get(url) and ignores cookies, so existing mock/test implementations keep compiling. Real HTTP clients should override this to attach the cookie header.

§Arguments
  • url - The URL to request
  • cookies - Raw Cookie header value (e.g. "sessionid=...; steamLoginSecure=...")
Source

fn post_form_with_cookies<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, url: &'life1 str, form: &'life2 [(&'life3 str, &'life4 str)], cookies: &'life5 str, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, SteamError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Perform a POST form request carrying a raw Cookie header value.

Default implementation delegates to post_form(url, form) and ignores cookies, so existing mock/test implementations keep compiling. Real HTTP clients should override this to attach the cookie header.

Trait Implementations§

Source§

impl HttpClient for dyn HttpClient

Source§

fn get_with_query<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, url: &'life1 str, query: &'life2 [(&'life3 str, &'life4 str)], ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, CmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Implementors§