Visitar URL original
Add sending trailers on Body channel · Issue #2260 · hyperium/hyper · GitHub
Skip to content

Add sending trailers on Body channel #2260

Closed

Description

@seanmonstar

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.

Activity

  1. added
    C-featureCategory: feature. This is adding a new feature.
    E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.
    A-bodyArea: body streaming.
    on Aug 4, 2020
  2. added a commit that references this issue on Jan 15, 2021
    bf8d74a
  3. added a commit that references this issue on Jul 26, 2021
    e49e711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-bodyArea: body streaming.C-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions