szmarczak / http2-wrapper

Use HTTP/2 the same way like HTTP/1
MIT License
239 stars 18 forks source link

Support sending request trailers #103

Open pimterry opened 6 months ago

pimterry commented 6 months ago

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:

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.