Struct awc::Client [−][src]
pub struct Client(_);
Expand description
An asynchronous HTTP and WebSocket client.
You should take care to create, at most, one Client
per thread. Otherwise, expect higher CPU
and memory usage.
Examples
use awc::Client;
#[actix_rt::main]
async fn main() {
let mut client = Client::default();
let res = client.get("http://www.rust-lang.org")
.insert_header(("User-Agent", "my-app/1.2"))
.send()
.await;
println!("Response: {:?}", res);
}
Implementations
pub fn builder(
) -> ClientBuilder<impl Service<ConnectInfo<Uri>, Response = TcpConnection<Uri, TcpStream>, Error = TcpConnectError> + Clone>
pub fn builder(
) -> ClientBuilder<impl Service<ConnectInfo<Uri>, Response = TcpConnection<Uri, TcpStream>, Error = TcpConnectError> + Clone>
Create Client
builder.
This function is equivalent of ClientBuilder::new()
.
Construct HTTP request.
pub fn request_from<U>(&self, url: U, head: &RequestHead) -> ClientRequest where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<HttpError>,
pub fn request_from<U>(&self, url: U, head: &RequestHead) -> ClientRequest where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<HttpError>,
Create ClientRequest
from RequestHead
It is useful for proxy requests. This implementation copies all headers and the method.
Construct HTTP GET request.
Construct HTTP HEAD request.
Construct HTTP PUT request.
Construct HTTP POST request.
Construct HTTP PATCH request.
Construct HTTP DELETE request.
Construct HTTP OPTIONS request.
Initialize a WebSocket connection. Returns a WebSocket connection builder.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more