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

Add sending trailers on Body channel #2260

Closed
seanmonstar opened this issue Aug 4, 2020 · 0 comments · Fixed by #2387
Closed

Add sending trailers on Body channel #2260

seanmonstar opened this issue Aug 4, 2020 · 0 comments · Fixed by #2387
Labels
A-body Area: body streaming. C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful.

Comments

@seanmonstar
Copy link
Member

The Body::channel() variant is a common simple way to send data as a Body. It would be useful to also be able to send trailers on it.

Implementation

The code to change is on the hyper::body::Sender, and the relevant Kind variant. I could imagine two possible ways to implement this, and I'm not sure which is better yet.

  1. Change the internal mpsc channel to send enum Msg { Data(Bytes), Trailers(HeaderMap) }. However, the Kind::Chan variant would need to grow some cache slots, since poll_data could pop a Msg::Trailers, and then that would need to cached so that poll_trailers returns its.
  2. Add a oneshot channel to send the trailers. The downside here is the increased size of Sender and Kind::Channel (they both are carrying an extra pointer), and the extra allocation.

I think the 2nd option is probably going to be better, but measurements are king. We should compare the changes to the benches/end_to_end results to see if the added feature makes much of a difference. If it does, we could consider making an internal "skinnier channel" that is used by the h1 dispatcher.

@seanmonstar seanmonstar added C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful. A-body Area: body streaming. labels Aug 4, 2020
BenxiangGe pushed a commit to BenxiangGe/hyper that referenced this issue Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-body Area: body streaming. C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful.
Projects
None yet
1 participant