socketry / async-http

MIT License
298 stars 45 forks source link

HTTP/2 does not require the Trailer header to be there #91

Closed Maaarcocr closed 2 years ago

Maaarcocr commented 2 years ago

It is my understanding that HTTP/2 does not necessary require the Trailer header to be there in order to have trailer headers. In https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer it seems to suggest that such header is defined in the specification of HTTP/1.1

I've been trying to make a grpc client that uses async-http as the transport and while trying to read back the response I get the Unable to process headers error that gets thrown here https://github.com/socketry/async-http/blob/bbe0f75c5da22d0534f24ff96deb7e9fb761cbe6/lib/async/http/protocol/http2/stream.rb#L82

This is due to the lack of the Trailer header in the initial headers, which then make it throw when we get some trailers but @trailer is not defined.

Given that HTTP/2 does not require such header to be there, could we change the logic in stream.rb such that it just reads the trailers and append them in the headers?