luasocket icon indicating copy to clipboard operation
luasocket copied to clipboard

http.request: handling of duplicated headers should be documented

Open johnd0e opened this issue 1 year ago • 3 comments

It is common to have multiple headers with the same title in an HTTP response. For example, consider Set-Cookie.

In the receiveheaders function, I see this code:

https://github.com/lunarmodules/luasocket/blob/1fad1626900a128be724cba9e9c19a6b2fe2bf6b/src/http.lua#L69

I am not sure if this practice is sort of standard, but it is not obvious and should be documented.

https://lunarmodules.github.io/luasocket/http.html#request

johnd0e avatar Oct 17 '24 20:10 johnd0e

as per http spec. header values can be comma separated in a single header, or appear multiple times. This just makes them appear once, in CSV format.

Tieske avatar Oct 18 '24 11:10 Tieske

as per http spec. header values can be comma separated in a single header, or appear multiple times. This just makes them appear once, in CSV format.

As the OP notes: some headers (such as Set-Cookie) must not be comma-concatenated as that would change semantics

daurnimator avatar Oct 18 '24 13:10 daurnimator

yup, that's right.

So then probably no combining should be done at all. The common way to handle would be to have the value become an array with mutliple entries. But that would be breaking 🤔

Tieske avatar Oct 20 '24 12:10 Tieske