Skip to content

How to read bytes from body #288

Answered by davidpdrsn
cemoktra asked this question in Q&A
Discussion options

You must be logged in to vote

You have a few options:

  • In axum you can use Bytes as an extractor which buffers the request body. It also provides other utilities. See FromRequest for everything that can be used as extractors.
  • Hyper provides to_bytes and aggregate that let you buffer the body into a Bytes.
  • axum::body::Body is a re-export of hyper::Body, which implements http_body::Body. That gives low level access to the byte stream.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by davidpdrsn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants