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

WIP: Allow multiple set-cookie headers #4829

Closed
wants to merge 9 commits into from
Closed

WIP: Allow multiple set-cookie headers #4829

wants to merge 9 commits into from

Conversation

Caesar2011
Copy link
Contributor

@Caesar2011 Caesar2011 commented Apr 20, 2020

Fixes #4826. The separator , is only allowed as a separator within Set-Cookie but not within other headers. This fix only works for Set-Cookie, the only standard-complient header witch is allowed to be set multiple times. Should this work for custom headers, too?

@CLAassistant
Copy link

CLAassistant commented Apr 20, 2020

CLA assistant check
All committers have signed the CLA.

@Caesar2011
Copy link
Contributor Author

Just a tiny change, no reason why it should break, and only break on ubuntu...

@Caesar2011 Caesar2011 changed the title Allow multiple set-cookie headers WIP: Allow multiple set-cookie headers Apr 21, 2020
@Caesar2011 Caesar2011 changed the title WIP: Allow multiple set-cookie headers Allow multiple set-cookie headers Apr 21, 2020
@Caesar2011
Copy link
Contributor Author

Before:

content-type: text/plain
set-cookie: user.session=qwertz; Max-Age=86400, a=123; Max-Age=86400, b=456; Max-Age=86400

After:

content-type: text/plain
set-cookie: user.session=qwertz; Max-Age=86400
set-cookie: a=123; Max-Age=86400
set-cookie: b=456; Max-Age=86400

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

Thanks @Caesar2011 - I wonder if you could include a test?

@Caesar2011
Copy link
Contributor Author

Caesar2011 commented Apr 21, 2020

Sure, could you give me a short instruction how or at least where I can find similar tests?

Edit: I think I've got an idea.... Wait.... :D

@Caesar2011 Caesar2011 changed the title Allow multiple set-cookie headers Allow multiple set-cookie headers (fix #4826) Apr 21, 2020
@Caesar2011 Caesar2011 changed the title Allow multiple set-cookie headers (fix #4826) Allow multiple set-cookie headers Apr 21, 2020
@Caesar2011 Caesar2011 changed the title Allow multiple set-cookie headers WIP: Allow multiple set-cookie headers Apr 21, 2020
} else {
value.split(/(?<!; expires\=\w+), /).forEach((v: string) => {
out += `${key}: ${v}\r\n`;
});
Copy link
Member

@ry ry Apr 21, 2020

Choose a reason for hiding this comment

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

I don't think this regex is the optimal way of achieving this... I don't think any extra parsing should be necessary to write out the response.

Copy link
Contributor Author

@Caesar2011 Caesar2011 Apr 21, 2020

Choose a reason for hiding this comment

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

I am with you. No extra parsing should be necessary. But using the Headers construction with string[][] as parameter multiple headers get concatenated with , . You need some way to split it again, but not split within the expire value. (See comment in associated issue)

Do you have any suggestions/inspirations?

Copy link
Contributor

Choose a reason for hiding this comment

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

I found the same issue yesterday and started working on it, didn't know there was already work being done. I have a working implementation with a different approach, I'll reference this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Caesar2011
Copy link
Contributor Author

Closed due to better approach in #4840

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.

Sending multiple Set-Cookie headers get merged
4 participants