Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http.request: handling of duplicated headers should be documented #441

Open
johnd0e opened this issue Oct 17, 2024 · 3 comments
Open

http.request: handling of duplicated headers should be documented #441

johnd0e opened this issue Oct 17, 2024 · 3 comments

Comments

@johnd0e
Copy link

johnd0e commented Oct 17, 2024

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:

if headers[name] then headers[name] = headers[name] .. ", " .. value

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

@Tieske
Copy link
Member

Tieske commented Oct 18, 2024

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.

@daurnimator
Copy link
Contributor

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

@Tieske
Copy link
Member

Tieske commented Oct 20, 2024

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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants