Skip to content

Conversation

@Gelbpunkt
Copy link
Owner

Should fix #119, cc @lehmanju

@Gelbpunkt Gelbpunkt force-pushed the switching-protocols-headers branch from 223d152 to c65bdbc Compare November 4, 2025 14:52
resp.extend_from_slice(ws_accept.as_bytes());
resp.extend_from_slice(b"\r\n");

for (name, value) in self.response_headers {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntoIter yields the same key multiple times in case of multiple values, yet http expects headers to be formated as key: value1,value2. You can use keys() and get_all() instead

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that done at some point in the implementation, but there are special cases to consider here (Set-Cookie). I'm not sure whether that's worth the added complexity considering this is probably going to be used to set 1-2 extra headers, if at all

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know about that exception. But we should document the behavior then.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to document that adding multiple values to a header may produce a noncompliant request

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting Sec-WebSocket-Protocol response header

3 participants