3 releases

new 0.1.2 Apr 26, 2025
0.1.1 Mar 10, 2025
0.1.0 Mar 9, 2025

#261 in HTTP client

Download history 223/week @ 2025-03-08 31/week @ 2025-03-15 3/week @ 2025-03-22 14/week @ 2025-03-29 31/week @ 2025-04-05 89/week @ 2025-04-12 51/week @ 2025-04-19

186 downloads per month
Used in tower-http-client

MIT/Apache

21KB
123 lines

http-body-reader

tests crates.io Documentation MIT/Apache-2 licensed

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.

Usage

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(())
}

License

This project is licensed under the MIT license.

Contribution

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.

Dependencies

~1.6–2.4MB
~47K SLoC