3 releases

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

#876 in Parser implementations

Download history 1/week @ 2025-03-20 7/week @ 2025-03-27 21/week @ 2025-04-03 88/week @ 2025-04-10 58/week @ 2025-04-17 259/week @ 2025-04-24 182/week @ 2025-05-01 126/week @ 2025-05-08 156/week @ 2025-05-15 140/week @ 2025-05-22 203/week @ 2025-05-29 150/week @ 2025-06-05 54/week @ 2025-06-12 213/week @ 2025-06-19 252/week @ 2025-06-26 190/week @ 2025-07-03

714 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.5MB
~49K SLoC