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

chore(volo-http): wrap hyper::body::Incoming by Body #504

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

yukiiiteru
Copy link
Member

In order to unify the body type within Volo-HTTP, this commit wraps hyper::body::Incoming by Body, so that both client and server can use http::Request and http::Response with Body.

In addition, with this commmit, client and server inside Volo-HTTP can communicate by function call without any connection, which is useful for testing.

Althrough hyper::body::Incoming implements http_body::Body, use enum rather than BoxBody can avoid overhead of memory allocating by Box and dynamic dispatch of dyn http_body::Body.

BREAK CHANGE:

  • ServerRequest has been changed from http::Request<hyper::body::Incoming> to http::Request<Body>
  • ClientResponse has been changed from http::Response<hyper::body::Incoming> to http::Response<Body>

These are imperceptible to most users.

In order to unify the body type within Volo-HTTP, this commit wraps
`hyper::body::Incoming` by `Body`, so that both client and server can
use `http::Request` and `http::Response` with `Body`.

In addition, with this commmit, client and server inside Volo-HTTP can
communicate by function call without any connection, which is useful
for testing.

Althrough `hyper::body::Incoming` implements `http_body::Body`, use
`enum` rather than `BoxBody` can avoid overhead of memory allocating
by `Box` and dynamic dispatch of `dyn http_body::Body`.

BREAK CHANGE:

- `ServerRequest` has been changed from
  `http::Request<hyper::body::Incoming>` to `http::Request<Body>`
- `ClientResponse` has been changed from
  `http::Response<hyper::body::Incoming>` to `http::Response<Body>`

These are imperceptible to most users.

Signed-off-by: Yu Li <[email protected]>
@yukiiiteru yukiiiteru requested review from a team as code owners September 26, 2024 10:20
@yukiiiteru
Copy link
Member Author

I've run script/selftest.sh on the stable toolchain and it passes, and all errors on CI so far are from rust-lang/rust-clippy#13458, which is a bug of clippy in the nightly toolchain and can be ignored for now.

@yukiiiteru yukiiiteru merged commit 566fcb5 into cloudwego:main Sep 26, 2024
7 of 15 checks passed
@yukiiiteru yukiiiteru deleted the chore/body-incoming branch September 26, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants