Crates.io | http-body-reader |
lib.rs | http-body-reader |
version | 0.1.2 |
created_at | 2025-03-09 19:24:02.707934+00 |
updated_at | 2025-04-26 14:58:45.525551+00 |
description | A convenient way to read the http body. |
homepage | |
repository | https://github.com/alekseysidorov/http-body-reader |
max_upload_size | |
id | 1585752 |
size | 72,317 |
This library provides an easy way to read the HTTP body in the most common formats such as UTF-8 encoded text, JSON, form data.
use http::Request;
use http_body_reader::ResponseExt as _;
use reqwest::Client;
use tower_reqwest::HttpClientService;
use tower_service::Service as _;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a new client
let mut client = HttpClientService::new(Client::new());
// Execute request by using this service.
let response = client
.call(Request::get("https://example.com").body(reqwest::Body::default())?)
.await?;
let text = response.body_reader().utf8().await?;
println!("{text}");
Ok(())
}
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in http-body-reader
by you, shall be licensed as MIT, without
any additional terms or conditions.