Skip to content

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

Merged
yukiiiteru merged 2 commits intocloudwego:mainfrom
yukiiiteru:chore/body-incoming
Sep 26, 2024
Merged

chore(volo-http): wrap hyper::body::Incoming by Body#504
yukiiiteru merged 2 commits intocloudwego:mainfrom
yukiiiteru:chore/body-incoming

Conversation

@yukiiiteru
Copy link
Copy Markdown
Contributor

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 <liyu.yukiteru@bytedance.com>
@yukiiiteru yukiiiteru requested review from a team as code owners September 26, 2024 10:20
@yukiiiteru
Copy link
Copy Markdown
Contributor 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
@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