- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Closed
Labels
A-bodyArea: body streaming.Area: body streaming.C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.Effort: medium. Some knowledge of how hyper internal works would be useful.
Description
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.
- Change the internal mpsc channel to send enum Msg { Data(Bytes), Trailers(HeaderMap) }. However, theKind::Chanvariant would need to grow some cache slots, sincepoll_datacould pop aMsg::Trailers, and then that would need to cached so thatpoll_trailersreturns its.
- Add a oneshotchannel to send the trailers. The downside here is the increased size ofSenderandKind::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.
koivunej, jeromegn and weihanglo
Metadata
Metadata
Assignees
Labels
A-bodyArea: body streaming.Area: body streaming.C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.Effort: medium. Some knowledge of how hyper internal works would be useful.