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

Handle multiple cookie values #2

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

Ptrskay3
Copy link
Contributor

@Ptrskay3 Ptrskay3 commented Jun 23, 2022

Fixes: #1

Request cookies - if multiple - are sent separated by ; (semicolon), and they can have arbitrary whitespace around them.
This PR adds the support for handling multiple cookies and finding the one with name session_layer.cookie_name.

Based on my (not too exhaustive) testing it works fine. I'm not sure the style could be improved.

request cookies - if multiple - are sent separated by ; (semicolon),
and they can have arbitrary whitspace around them.

This commit adds the support for handling multiple cookies and finding
the one with name `session_layer.cookie_name`.
.map(|cookie| cookie.trim())
.filter_map(|cookie| Cookie::parse_encoded(cookie).ok())
.filter(|cookie| cookie.name() == session_layer.cookie_name)
.find_map(|cookie| self.layer.verify_signature(cookie.value()).ok())
Copy link
Owner

Choose a reason for hiding this comment

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

Did not know about find_map; neat!

@maxcountryman
Copy link
Owner

Thank you for this!

@maxcountryman maxcountryman merged commit 5c11521 into maxcountryman:main Jun 23, 2022
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.

Handle multiple cookie values sent in a request
3 participants