ostinelli / net-http2

NetHttp2 is an HTTP/2 client for Ruby.
MIT License
140 stars 31 forks source link

Let make the client's pseudo-header handling a little more rfc7540 compliant #21

Closed gonubana closed 6 years ago

gonubana commented 7 years ago

According to rfc7540 (Section 8.1.2.1), "All pseudo-header fields MUST appear in the header block before regular header fields". Making the request headers in the :headers option be a 2d array instead of a hash could help the client in being compliant with this requirement. Plus, with a 2d array, we can make a request with multiple headers of the same name (like multiple 'cookie' headers) which we can not do with a hash.

ostinelli commented 7 years ago

Hashes are already ordered in Ruby:

Hashes enumerate their values in the order that the corresponding keys were inserted.

[reference]

Can you please expand?

gonubana commented 7 years ago

1) Pseudo-headers are currently inserted after custom headers provided through Client#prepare_request. 2) When the 2d array containing headers from the server gets converted into a hash, some headers get lost. This happens, for example, when the server sends several "Set-Cookie:" headers.

ostinelli commented 7 years ago

Got it. Care to issue a pull request?

ostinelli commented 6 years ago

This will be covered when changes discussed in https://github.com/igrigorik/http-2/pull/132 get applied. Closing but keeping track of the second point in https://github.com/ostinelli/net-http2/issues/27