inaka/shotgun

HTTP spec allows multiple headers with the same key

Opened this issue · 2 comments

Using a map to represent headers is therefore wrong.

Example is multiple Set-Cookie headers.

Perhaps I'm misinterpreting this, but the second-to-last paragraph of section 3.2.2 of RFC 7230 [0] seems to permit exactly what we're doing.... assuming that we're joining the additional field-values to the first field-value in a comma-separated list:

A recipient MAY combine multiple header fields with the same field
name into one "field-name: field-value" pair, without changing the
semantics of the message, by appending each subsequent field value to
the combined field value in order, separated by a comma. The order
in which header fields with the same field name are received is
therefore significant to the interpretation of the combined field
value; a proxy MUST NOT change the order of these field values when
forwarding a message.

Amusingly, in the next paragraph, the Set-Cookie headers behavior that you mention is explicitly called out as non-compliant, but is a widely-used violation that -in practice- requires special casing.

[0] https://tools.ietf.org/html/rfc7230#section-3.2.2

I agree with the fact that multiple headers (except Set-Cookie headers) could be sent as a comma separated list under the same header entry. However, for the sake of convention/compatibility with gun and handling that edge case with cookies, I'd say supporting both maps/proplist as headers should be allowed.

This is a related issue I submitted a couple days ago: #125