http-body-reader 0.1.2

A convenient way to read the http body.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use http::Response;
use http_body_reader::ResponseExt as _;
use http_body_util::Full;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create a new response with the given text as the body.
    let message = "Hello world";
    let response = Response::builder().body(Full::new(message.as_ref()))?;
    // Read the response body as UTF-8 and check that it matches the original message.
    assert_eq!(response.body_reader().utf8().await?, message);

    Ok(())
}