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

Support sending request trailers #103

Open
pimterry opened this issue Apr 29, 2024 · 0 comments
Open

Support sending request trailers #103

pimterry opened this issue Apr 29, 2024 · 0 comments

Comments

@pimterry
Copy link
Contributor

ClientRequest doesn't include the addTrailers method so trailers cannot be added to outgoing requests.

This takes a little thought, since the H1 API allows adding trailers at effectively any time until the response is closed, while the H2 API requires:

  • Setting waitForTrailers: true when creating the initial request - this disables stream auto-closing after the body is sent
  • Waiting for the wantTrailers event
  • Calling sendTrailers - this appends the trailers and closes the stream

I think the best solution is to always set wantTrailers: true and then manually call stream.close() every time that addTrailers hasn't been called before the body ends (assuming nothing else has closed the stream and there's no errors etc). I think that should result in more or less the same behaviour as H1.

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

No branches or pull requests

1 participant