1 unstable release
Uses new Rust 2024
new 0.1.0-alpha3 | Mar 12, 2025 |
---|
#642 in HTTP client
47KB
1K
SLoC
Async HTTP requests for tokio runtime.
This crate is a part of areq library, the runtime-independent HTTP requests. If you want your code to run in tokio runtime, this crate is the right choice.
Getting Started
To create an HTTP client, you need to choose a protocol version it'll support. For example, let's use HTTP/1.1. Add the dependency and the required features to a project:
cargo add areq-tokio -F http1
Now you can connect to a remote server, establish an HTTP connection and perform a request:
use {
areq_tokio::{areq::{http::Uri, http1::Http1}, prelude::*},
std::io::Error,
};
async fn get() -> Result<String, Error> {
let addr = Uri::from_static("http://127.0.0.1:3001");
let (mut client, conn) = Http1::default().connect(addr).await?;
tokio::spawn(conn);
let path = Uri::from_static("/hello");
client.get(path).await?.text().await
}
Dependencies
~5–16MB
~208K SLoC