pub struct HttpClient { /* private fields */ }Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(browser_profile: BrowserProfile) -> Result<Self, NetError>
pub fn new(browser_profile: BrowserProfile) -> Result<Self, NetError>
Create a new client with an isolated session and the given browser profile.
Sourcepub fn with_session(
session: Arc<SharedSession>,
browser_profile: BrowserProfile,
) -> Result<Self, NetError>
pub fn with_session( session: Arc<SharedSession>, browser_profile: BrowserProfile, ) -> Result<Self, NetError>
Build a client that participates in a provided shared session.
pub fn browser_profile(&self) -> &BrowserProfile
Sourcepub fn has_accept_ch(&self, host: &str) -> bool
pub fn has_accept_ch(&self, host: &str) -> bool
Whether host has previously sent Accept-CH.
Snapshot all cookies for a URL.
Inject cookies from external sources (e.g., JS document.cookie).
Set a single cookie from a raw Set-Cookie-style string.
Drop all cookies matching target_domain.
Sourcepub async fn get(&self, url: &str) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() instead
pub async fn get(&self, url: &str) -> Result<Response, NetError>
Use HttpClient::request() instead
Perform a GET request.
Sourcepub async fn get_with_headers(
&self,
url: &str,
extra_headers: &[(String, String)],
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() instead
pub async fn get_with_headers( &self, url: &str, extra_headers: &[(String, String)], ) -> Result<Response, NetError>
Use HttpClient::request() instead
GET with extra headers.
Sourcepub async fn fetch_get(
&self,
url: &str,
extra_headers: &[(String, String)],
_origin: Option<&str>,
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() with explicit headers instead
pub async fn fetch_get( &self, url: &str, extra_headers: &[(String, String)], _origin: Option<&str>, ) -> Result<Response, NetError>
Use HttpClient::request() with explicit headers instead
Fetch-API-style GET with accept: */* semantics.
Sourcepub async fn fetch_post_bytes(
&self,
url: &str,
body: &[u8],
extra_headers: &[(String, String)],
_origin: Option<&str>,
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() with explicit headers instead
pub async fn fetch_post_bytes( &self, url: &str, body: &[u8], extra_headers: &[(String, String)], _origin: Option<&str>, ) -> Result<Response, NetError>
Use HttpClient::request() with explicit headers instead
Fetch-API-style POST with raw bytes.
Sourcepub async fn post(&self, url: &str, body: &str) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() instead
pub async fn post(&self, url: &str, body: &str) -> Result<Response, NetError>
Use HttpClient::request() instead
Perform a POST request with a string body.
Sourcepub async fn post_with_headers(
&self,
url: &str,
body: &str,
extra_headers: &[(String, String)],
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() instead
pub async fn post_with_headers( &self, url: &str, body: &str, extra_headers: &[(String, String)], ) -> Result<Response, NetError>
Use HttpClient::request() instead
POST with extra headers.
Sourcepub async fn post_bytes_with_headers(
&self,
url: &str,
body: &[u8],
extra_headers: &[(String, String)],
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() instead
pub async fn post_bytes_with_headers( &self, url: &str, body: &[u8], extra_headers: &[(String, String)], ) -> Result<Response, NetError>
Use HttpClient::request() instead
POST with raw bytes and extra headers.
Sourcepub async fn get_follow(
&self,
url: &str,
max_redirects: u8,
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() with RedirectPolicy::Follow(n) instead
pub async fn get_follow( &self, url: &str, max_redirects: u8, ) -> Result<Response, NetError>
Use HttpClient::request() with RedirectPolicy::Follow(n) instead
GET with explicit redirect following.
Sourcepub async fn get_follow_with_headers(
&self,
url: &str,
extra_headers: &[(String, String)],
max_redirects: u8,
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() with RedirectPolicy::Follow(n) instead
pub async fn get_follow_with_headers( &self, url: &str, extra_headers: &[(String, String)], max_redirects: u8, ) -> Result<Response, NetError>
Use HttpClient::request() with RedirectPolicy::Follow(n) instead
GET with extra headers and redirect following.
Sourcepub async fn post_follow(
&self,
url: &str,
body: &str,
max_redirects: u8,
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() with RedirectPolicy::Follow(n) instead
pub async fn post_follow( &self, url: &str, body: &str, max_redirects: u8, ) -> Result<Response, NetError>
Use HttpClient::request() with RedirectPolicy::Follow(n) instead
POST with redirect following. 307/308 preserve the body.
Sourcepub async fn post_bytes_follow(
&self,
url: &str,
body: &[u8],
extra_headers: &[(String, String)],
max_redirects: u8,
) -> Result<Response, NetError>
👎Deprecated: Use HttpClient::request() with RedirectPolicy::Follow(n) instead
pub async fn post_bytes_follow( &self, url: &str, body: &[u8], extra_headers: &[(String, String)], max_redirects: u8, ) -> Result<Response, NetError>
Use HttpClient::request() with RedirectPolicy::Follow(n) instead
POST with raw bytes and redirect following.
Sourcepub async fn preconnect(&self, url: &str) -> Result<(), NetError>
pub async fn preconnect(&self, url: &str) -> Result<(), NetError>
Pre-establish a connection to a host. hpx handles connection pooling internally, so this is a lightweight GET that warms the pool.
Sourcepub async fn request(
&self,
method: &str,
url: &str,
body: Option<&[u8]>,
extra_headers: &[(String, String)],
policy: RedirectPolicy,
) -> Result<Response, NetError>
pub async fn request( &self, method: &str, url: &str, body: Option<&[u8]>, extra_headers: &[(String, String)], policy: RedirectPolicy, ) -> Result<Response, NetError>
Unified request dispatch — single entry point for all HTTP verbs.
method: HTTP verb string (e.g. “GET”, “POST”). url: target.
body: optional request body. extra_headers: appended after cookies.
policy: redirect following behaviour.
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more