-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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 a way to set custom cookie parsers #34081
base: main
Are you sure you want to change the base?
Add a way to set custom cookie parsers #34081
Conversation
Add a way to set custom cookie parsers to be compliant with rfc6265 section 4.1.1
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.
We could consider a Parser
contract in ResponseCookie
to customize parsing in client responses, but first could you add a little more detail around what you want to customize?
Hi @rstoyanchev , Thanks for the feedback. So things like expiration and similar are after the cookie-pair, but the section states that:
So it is not a MUST NOT, it is a SHOULD NOT. We have a case where an external provider send Set-Cookie headers with a different syntax, such as prefixing the cookie-pair with cookie-av (which is not "totally" against the current version of the RFC). Unfortunately we have no control on the provider and the HttpCookie from java.net is relying on rfc2965 (which was in fact a MUST NOT), so it fails at parsing time. It would be nice to have a way to set a custom cookie parser, such that the way the Set-Cookie header is managed is actually customizable. In the PR I've proposed a way to abstract the feature, let me know if is it fine; I have to align the branch with the current upstream, I can do that if the proposal is fine. Thanks, |
I think we can do this, but I would move the contract to |
Yeap, that is fine :) |
Yes, feel to free to send updates. |
Ok thank you, I will update the PR asap :) |
Add a way to set custom cookie parsers to be compliant with rfc6265 section 4.1.1
java.net.HttpCookie::parse still follows rfc2965: https://docs.oracle.com/javase/8/docs/api/java/net/HttpCookie.html#parse-java.lang.String-
That has been obsoleted from rfc6265: https://datatracker.ietf.org/doc/html/rfc6265
That in section 4.1.1 states the following:
So the MUST constraint from rfc2965 has been relaxed to SHOULD NOT in rfc6265
I think that taking this into account, it may also be a good idea to collapse some features between the Jetty response connector and the JDK response connector, and provide a way to customize the cookie parser.