Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body implementation on Request #3

Closed
wants to merge 1 commit into from
Closed

Conversation

evmer
Copy link

@evmer evmer commented Sep 2, 2022

No description provided.

@evmer evmer mentioned this pull request Sep 3, 2022
@StratusFearMe21
Copy link

StratusFearMe21 commented Nov 21, 2022

This looks great, however, it's not ideal. I think we can do better 😀! I'm thinking an API like this

  • req.body.resolve() -- Copies the body into a Bytes and returns it
  • impl Read for Body -- the req.body object would implement std::io::Read, allowing the user to read the body as it's coming in, saving allocations

Im thinking that req.body could contain a tuple struct (struct Body(TcpStream)) that implements this API. We could read the TcpStream just enough to parse an HTTP request, then stop reading before the body, allowing the user to decide whether they want to req.body.read() or req.body.resolve()

When I get the time ill definitely make a PR of my own for this, but if you beat me to it, that's cool too!

@Xudong-Huang
Copy link
Owner

close this since we already have a better solution, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants