Struct opendal::raw::HttpClient
source · pub struct HttpClient { /* private fields */ }
Expand description
HttpClient that used across opendal.
Implementations§
source§impl HttpClient
impl HttpClient
sourcepub fn with_client(async_client: Client, sync_client: Agent) -> Self
pub fn with_client(async_client: Client, sync_client: Agent) -> Self
Build a new http client from already built clients.
Notes
By using this method, it’s caller’s duty to make sure everything configured correctly. Like proxy, dns resolver and so on.
And this API is an internal API, OpenDAL could change it while bumping minor versions.
Reminders
no auto redirect
OpenDAL will handle all HTTP responses, including redirections. Auto redirect may cause OpenDAL to fail.
For reqwest client, please make sure your client’s redirect policy is Policy::none()
.
let _client = reqwest::ClientBuilder::new()
.redirect(Policy::none())
.build()?;
For ureq client, please make sure your client’s redirect count is 0
:
let _client = ureq::AgentBuilder::new().redirects(0).build();
sourcepub fn async_client(&self) -> Client
pub fn async_client(&self) -> Client
Get the async client from http client.
sourcepub fn sync_client(&self) -> Agent
pub fn sync_client(&self) -> Agent
Get the sync client from http client.
sourcepub fn send(&self, req: Request<Body>) -> Result<Response<Body>>
pub fn send(&self, req: Request<Body>) -> Result<Response<Body>>
Send a request in blocking way.
sourcepub async fn send_async(
&self,
req: Request<AsyncBody>
) -> Result<Response<IncomingAsyncBody>>
pub async fn send_async( &self, req: Request<AsyncBody> ) -> Result<Response<IncomingAsyncBody>>
Send a request in async way.
Trait Implementations§
source§impl Clone for HttpClient
impl Clone for HttpClient
source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more