-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add Cookie#setAttribute #399
Add Cookie#setAttribute #399
Conversation
Some thoughts:
|
Since you are touching the RFC / version details in the javadoc, do we want to mention that RFC2109 is obsolete and replaced with RFC2965 which is also now obsolete and replaced with RFC6265. |
Candidate for a new ticket/PR indeed but not applicable in current context. |
This PR is especially timely, considering that Chrome and Firefox devs are discussing a new
|
It looks that cloned Cookie shares |
* @since Servlet 5.1 | ||
*/ | ||
public void setAttribute(String name, String value) { | ||
if (name == null || name.isEmpty()) { |
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 implementation here needs to enforce the apidoc above that says:
This should override any predefined attribute for which already a getter/setter pair exist in the current version.
This can be done be removing all the fields and using only the map to store the attributes (and then updating the getters/setters accordingly). Alternately, known fields can be intercepted here and call the setters directly.
Eitherway, we need for the known fields to always appear in the map or to never appear in the map, and never have different values if they appear in both.
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.
Alternately, known fields can be intercepted here and call the setters directly.
That won't work in long term. An good example is the earlier proposal to make SameSite
an enum. We want the API to behave in best possible compatible way when HTTP guys at some point decide to add a new value to the enumeration.
This can be done be removing all the fields and using only the map to store the attributes (and then updating the getters/setters accordingly).
It could only work if we redocument non-String getter methods to throw some runtime exception when an "incompatible" value was set via setAttribute().
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've prepped another PR for this: #400
Closing off. This is superseded by #400 |
* Add Cookie#setAttribute #175 #271 * Skip null value from check for reserved token * Alternative approach to cookie attribute handling github.com//pull/399#discussion_r624276777 * Make sure path is referenced via constant * In hindsight, token check doesn't need to be performed on value * Match casing with spec; mapping is case insensitive anyway * Optimized Cookie to lazily create attribute map * Added junit test * Updates from review * Fixed quote * surefire plugin * Updates from review * Updates from review Co-authored-by: Bauke Scholtz <balusc@gmail.com>
For discussion, see #175 and #271
While at it I also took opportunity to:
isToken
helper method whose comment and methodname were completely out of sync with actual implementation