[−][src]Struct surf::Client
An HTTP client, capable of creating new Request
s.
Examples
let client = surf::Client::new(); let req1 = client.get("https://httpbin.org/get").recv_string(); let req2 = client.get("https://httpbin.org/get").recv_string(); let (str1, str2) = futures::future::try_join(req1, req2).await?;
Implementations
impl Client<NativeClient>
[src]
impl<C: HttpClient> Client<C>
[src]
pub fn get(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP GET
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.get("https://httpbin.org/get").recv_string().await?;
pub fn head(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP HEAD
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.head("https://httpbin.org/head").recv_string().await?;
pub fn post(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP POST
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.post("https://httpbin.org/post").recv_string().await?;
pub fn put(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP PUT
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.put("https://httpbin.org/put").recv_string().await?;
pub fn delete(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP DELETE
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.delete("https://httpbin.org/delete").recv_string().await?;
pub fn connect(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP CONNECT
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.connect("https://httpbin.org/connect").recv_string().await?;
pub fn options(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP OPTIONS
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.options("https://httpbin.org/options").recv_string().await?;
pub fn trace(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP TRACE
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.trace("https://httpbin.org/trace").recv_string().await?;
pub fn patch(&self, uri: impl AsRef<str>) -> Request<C>
[src]
Perform an HTTP PATCH
request using the Client
connection.
Panics
This will panic if a malformed URL is passed.
Errors
Returns errors from the middleware, http backend, and network sockets.
Examples
let client = surf::Client::new(); let string = client.patch("https://httpbin.org/patch").recv_string().await?;
Trait Implementations
impl<C: Debug + HttpClient> Debug for Client<C>
[src]
impl<C: Default + HttpClient> Default for Client<C>
[src]
Auto Trait Implementations
impl<C> RefUnwindSafe for Client<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Send for Client<C>
impl<C> Sync for Client<C>
impl<C> Unpin for Client<C>
impl<C> UnwindSafe for Client<C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,