A Boston
A Boston

Reputation: 296

Read body as bytes using Hyper release 1.4

A long awaited upgrade to hyper 1.4 (from pre release possibly 0.13 ) has been successful except for one outstanding issue: Reading the body.

It is no longer possible to read the request body as bytes using

hyper::body::to_bytes(req)

Does anyone have experience with the release or latest version of hyper reading the body?

Noting the body contain json data which was converted to a str in the following fashion

std::str::from_utf8(&bytes)
json::parse(data)

Upvotes: 1

Views: 344

Answers (1)

A Boston
A Boston

Reputation: 296

Some clues are found in the echo example.

The following on line 64 of the above code provided the needed fruit.

let whole_body = req.collect().await?.to_bytes();

where req: Request<hyper::body::Incoming> opposed to req: Request<Body> in pre 1.0 release and use http_body_util::BodyExt;

Upvotes: 0

Related Questions