-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Make header.Set reset cookies instead of adding them #1864
Open
sigmundxia
wants to merge
5
commits into
valyala:master
Choose a base branch
from
sigmundxia:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
439995e
Clear cookies before setting
sigmundxia 306ebbe
Adjust set cookie test
sigmundxia 58f8ccd
Adjust for lint
sigmundxia baf3dbf
Use empty string description in test
sigmundxia c2f49c8
Adjust the method of resetting cookies && add corresponding tests
sigmundxia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setSpecialHeader method is used in both the Set and Add methods of Header, so modifying it will affect its usage in Add. To reduce code duplication, an additional parameter can be added to setSpecialHeader, or h.Cookies can be reset before calling setSpecialHeader based on the parent method. Resetting h.Cookies can be done using RequestHeader.DelAllCookies's zero slice strategy, as using make may result in unnecessary memory allocation.
Such a pull request may not necessarily be accepted by @erikdubbelboer, but personally, I would accept it. Why not give it a try? 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much! I didn't notice that
Add
also uses thesetSpecialHeader
method, sorry for that oversight. I reimplemented the process of resetting cookies based on your suggestion.I also noticed that ResponseHeader should also have corresponding changes, so I changed it accordingly. In addition, I added tests for each case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the downstream issue you mentioned.
gofiber/fiber#3089 should be fixed under your two pull requests: this and #1860.
gofiber/fiber#3089 (comment)
Error: "[cookieOne=valueCookieOne cookieTwo=valueCookieTwo 0ookieOne=valueCookieOne cookieTwo=valueCookieTwo]" should have 2 item(s), but has 4
You're great!