socketry / protocol-http1

MIT License
6 stars 14 forks source link

Parse HTTP `connection` header as case-insensitive. #3

Closed BMorearty closed 5 years ago

BMorearty commented 5 years ago

Although HTTP header values are case-sensitive in general, RFC 7230 https://tools.ietf.org/html/rfc7230#section-6.1 says: "Connection options are case-insensitive."

See also:

An alternative is to move this logic into to protocol-http gem, but it would have to be specific to the connection header because many other headers are case-sensitive. If you want it there, the logic would go in the []= method to avoid having to check in multiple places (fields, each, extract, to_h, inspect, ==).

ioquatix commented 5 years ago

Let’s start with this but yeah maybe it needs to work with HTTP/2?

BMorearty commented 5 years ago

Good question...I haven't studied HTTP/2 and don't know if the Connection header is the same.

ioquatix commented 5 years ago

So just after I posted I realised the connection header is not used in HTTP/2. Also if you use different cases when things are case insensitive, hpack would be less effective.

Just wondering if we should consider doing this in Protocol::HTTP::Headers. Shared or general HTTP semantics should go in there

ioquatix commented 5 years ago

I reworked this slightly and moved the logic into Protocol::HTTP::Headers. I think it's more logical to do that. Released both gems. But I'll need to check how this behaves in async-http and perhaps update that too.