pub struct HttpClient { /* private fields */ }Expand description
A configured outbound HTTP client. Cheap to clone (wraps an Arc’d pool).
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn api() -> HttpClientBuilder
pub fn api() -> HttpClientBuilder
Builder for an API-style buffered client.
Sourcepub fn sse() -> HttpClientBuilder
pub fn sse() -> HttpClientBuilder
Builder for an SSE streaming client.
Sourcepub fn builder(profile: Profile) -> HttpClientBuilder
pub fn builder(profile: Profile) -> HttpClientBuilder
Builder for an explicit profile.
Sourcepub async fn get(&self, url: &str) -> Result<BoundedResponse, HttpError>
pub async fn get(&self, url: &str) -> Result<BoundedResponse, HttpError>
GET returning a buffered, size-bounded response (error statuses are
returned as HttpError::Status).
Sourcepub async fn get_with(
&self,
url: &str,
opts: RequestOptions,
) -> Result<BoundedResponse, HttpError>
pub async fn get_with( &self, url: &str, opts: RequestOptions, ) -> Result<BoundedResponse, HttpError>
GET with per-request options.
Sourcepub async fn post_json(
&self,
url: &str,
body: &Value,
) -> Result<BoundedResponse, HttpError>
pub async fn post_json( &self, url: &str, body: &Value, ) -> Result<BoundedResponse, HttpError>
POST a JSON body returning a buffered, size-bounded response.
Sourcepub async fn post_json_with(
&self,
url: &str,
body: &Value,
opts: RequestOptions,
) -> Result<BoundedResponse, HttpError>
pub async fn post_json_with( &self, url: &str, body: &Value, opts: RequestOptions, ) -> Result<BoundedResponse, HttpError>
POST a JSON body with per-request options.
Sourcepub async fn post_multipart_with(
&self,
url: &str,
form: Form,
opts: RequestOptions,
) -> Result<BoundedResponse, HttpError>
pub async fn post_multipart_with( &self, url: &str, form: Form, opts: RequestOptions, ) -> Result<BoundedResponse, HttpError>
POSTs a multipart/form-data body with per-request options.
A multipart form cannot be replayed (parts may stream from non-cloneable
sources), so this performs exactly ONE send attempt: no retries, not
even on a connect failure or retriable status. The total deadline,
cancellation token and response size bound still apply. The response
body is buffered like HttpClient::post_json_with.
Sourcepub async fn open_sse(
&self,
url: &str,
body: Option<&Value>,
opts: RequestOptions,
) -> Result<SseStream, HttpError>
pub async fn open_sse( &self, url: &str, body: Option<&Value>, opts: RequestOptions, ) -> Result<SseStream, HttpError>
Opens an SSE byte stream. Retries cover only stream establishment; once a successful response header set is returned the stream runs to completion without reconnecting.
Named open_sse (not sse) because HttpClient::sse is the
SSE-profile builder constructor.