-
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
Reactive HttpComponentsClientHttpResponse
ignores Expires
cookie attribute
#33157
Comments
HttpComponentsClientHttpResponse
ignores Expires
cookie attribute
Good catch.
So, in general, it's |
This comment was marked as outdated.
This comment was marked as outdated.
@sbrannen Netty: io.netty.handler.codec.http.cookie.ClientCookieDecoder.mergeMaxAgeAndExpires() merges Max-Age and Expires into Max-Age. Netty merges these two attributes using logic defined in RFC 6265. Point 3 of section 5.3 in this RFC gives higher precedence to Max-Age over Expires. And org.springframework.http.client.reactive.ReactorClientHttpResponse.getCookies() only considers maxAge which is okay for this case as Max-Age and Expires is already merged internally by Netty. So, no issues in org.springframework.http.client.reactive.ReactorClientHttpResponse. Apache: Unlike Netty, Apache is not merging max age and expires. Since org.springframework.http.client.reactive.HttpComponentsClientHttpResponse is an implementation of Apache HttpComponents HttpClient 5.x, I believe it's adaptCookies() method should process both Max-Age and Expires in ResponseCookie just like Apache. For fix, we can add Expires attribute to ResponseCookie. And in case of org.springframework.http.client.reactive.HttpComponentsClientHttpResponse.adaptCookies(), we set expires attribute if present. Can I go ahead and raise a PR with this? |
Hi @imvtsl, We discussed this within the team and decided to update the logic in We will also need to ensure that we have If any of those other implementations lack support for handling If you would like to submit a PR for this, feel free to do so. Otherwise, I will get to it in the coming weeks. Cheers, Sam |
Hey @sbrannen Out of curiosity, why do we deviate from the approach of Apache HttpComponents HttpClient 5.x where they do not merge |
Hi @imvtsl,
You're very welcome.
That would be much appreciated. 👍
We do not wish to modify the API for
Yes, that's correct. We want the handling to be internal and transparent to the user, without changes to the current public APIs. Cheers, Sam |
Hi @sbrannen It fails for Reactor Netty 2 and HttpComponents. I will raise the fix very soon. Thanks! |
I have raised the PR with fix and tests. |
Hey @sbrannen Please let me know if there is anything required from my end. I will be on vacation from Thursday to Monday. I will be available to do changes until tomorrow, otherwise I can do them after I come back on Tuesday. Thanks! |
A cookie has the optional attributes
Expires
andMax-Age
. If both are set, the latter takes precedence.In method
adaptCookies()
of classorg.springframework.http.client.reactive.HttpComponentsClientHttpResponse
each HttpComponentsCookie
is converted to a SpringResponseCookie
.Given is an HttpComponents
Cookie
which has setExpires
only, sinceadaptCookies()
just readsMax-Age
fromCookie
, the resultingResponseCookie
has lost its expiration information.Note: I have also checked
ReactorClientHttpResponse
, and it is not affected. Netty internally convertsExpires
toMax-Age
. Thus, itsCookie
class supportsMax-Age
only.The text was updated successfully, but these errors were encountered: