Crate awc

source ·
Expand description

awc is an asynchronous HTTP and WebSocket client library.

GET Requests

// create client
let mut client = awc::Client::default();

// construct request
let req = client.get("")
    .insert_header(("User-Agent", "awc/3.0"));

// send request and await response
let res = req.send().await?;
println!("Response: {:?}", res);

POST Requests

Raw Body

let mut client = awc::Client::default();
let response ="")
    .send_body("Raw body contents")


let request = serde_json::json!({
    "lang": "rust",
    "body": "json"

let mut client = awc::Client::default();
let response ="")

URL Encoded Form

let params = [("foo", "bar"), ("baz", "quux")];

let mut client = awc::Client::default();
let response ="")

Response Compression

All official and common content encoding codecs are supported, optionally.

The Accept-Encoding header will automatically be populated with enabled codecs and added to outgoing requests, allowing servers to select their Content-Encoding accordingly.

Feature flags enable these codecs according to the table below. By default, all compress-* features are enabled.

compress-gzipgzip, deflate


use futures_util::{SinkExt as _, StreamExt as _};

let (_resp, mut connection) = awc::Client::new()


let response =;
assert_eq!(response, awc::ws::Frame::Text("Echo".into()));


pub use cookie;


Traits and structures to aid consuming and writing HTTP payloads.
HTTP client errors
Various HTTP related types.
Test helpers for actix http client to use during testing.
Websockets client


An asynchronous HTTP and WebSocket client.
An HTTP Client builder
An HTTP Client request builder
Client Response
Manages HTTP client network connectivity.
FrozenClientRequest struct represents cloneable client request.
Builder that allows to modify extra headers.
A Future that reads a body stream, parses JSON, resolving to a deserialized T.
A Future that reads a body stream, resolving as Bytes.


Combined HTTP and WebSocket request type received by connection service.
Combined HTTP response & WebSocket tunnel type returned from connection service.
Future that sends request’s payload and resolves to a server response.

Type Definitions