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

[feat] Support trailer headers #1707

Open
2 tasks done
kuba-orlik opened this issue Nov 6, 2022 · 2 comments
Open
2 tasks done

[feat] Support trailer headers #1707

kuba-orlik opened this issue Nov 6, 2022 · 2 comments
Milestone

Comments

@kuba-orlik
Copy link

Describe the feature

Support HTTP Trailer headers that come after the response body:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
@sairamireddy6
Copy link

sairamireddy6 commented Dec 30, 2023

The support for HTTP Trailer headers that come after the response body is a feature that enhances the capabilities of the HTTP protocol. In traditional HTTP responses, headers are sent before the actual response body. However, with the inclusion of Trailer headers, certain headers can be sent after the response body.

Trailer headers provide a way to include additional metadata or information related to the response, even if the response body has already started streaming. This feature is particularly useful in scenarios where certain headers can only be determined or generated after the response body has been processed.

Here's a breakdown of the key aspects of this feature:

  1. HTTP Trailers: Trailers are a set of headers that are sent after the response body. They allow for the inclusion of additional information that may not be known or calculable until the server has generated the response body.
  2. Late-Binding Headers: This feature allows for "late-binding" of headers, meaning that certain headers can be determined or generated dynamically after the response body has started to be transmitted.
  3. Use Cases:
  • Integrity Verification: Trailers can be used for sending integrity verification information, such as checksums or hashes, for the response body.
  • Size Information: If the size of the response body is not known in advance, trailers can be used to communicate the actual size after transmission has started.
  • Custom Metadata: Applications may use trailers to send custom metadata or information related to the response.

Enhanced Flexibility: By supporting Trailer headers after the response body, the HTTP protocol becomes more flexible and adaptable to a wider range of use cases where dynamic or late-binding of headers is necessary.

It's important to note that not all clients or servers may support this feature, so its effective use may depend on the capabilities of both the sender (server) and the recipient (client) in an HTTP communication.

@kuba-orlik @olleolleolle @jed @kimjoar @sairamireddy6

@jonathanong jonathanong added this to the v3.0.0 milestone Aug 29, 2024
@jonathanong
Copy link
Member

https://nodejs.org/api/http.html#responseaddtrailersheaders

I think this will be a little tricky with streams as Koa would need to call .end() itself instead of the pipe. need to see how others do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants