-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Jetty 12 Cookie format incompatible by default with Apache HTTP Client 4.5.14 #12771
Comments
The syntax But that doesn't matter, as Apache HttpClient is actually violating the HTTP spec by not accepting all 3 date/time formats. Also, the standard RFC1123 format has been preferred since 1997.
The rule, since 1997, has been that User-Agents and Servers MUST generate the RFC1123 style dates everywhere in the HTTP headers (even the various Cookie headers), and accept all 3 date formats. (this part, the "accept all 3 date formats", is where Apache HttpClient is failing to follow the spec) This was discussed and fixed in Jetty 12.0.9 for both Jetty Server and Jetty HttpClient ... |
Thanks @joakime for the detailed and comprehensive response. I did a little more debugging, and found that by default Apache HTTP Client uses this pattern for matching the Expires parameter: Whilst I don't doubt that Jetty is following the specs (and I am very thankful for that), and I agree that the issue is with the Apache HTTP Client, it does however seem strange to me that this change in Jetty was not behind some sort of configuration knob. It feels a bit jarring to upgrade Jetty from version 11 to 12 whilst keeping the Jetty configuration options the same, and only then to find out that our (and other peoples) client applications have broken. In this instance, I can of course fix our client code... but I can't fix other people's clients for them. Anyway - thank you very much for Jetty and your and others hard work on it :-) |
Yup, and the format you copy/pasted, |
@joakime Actually I think there must be something more happening:
|
Correction, it doesn't work with your old Apache HTTPClient and Apache HTTPClient configuration. You have 2 choices.
Just to note, even the ships-with-java |
Jetty version(s)
Jetty Environment
Java version/vendor
OS type/version
Description
In the HTTP response, the format of the
Expires
parameter within the HTTPSet-Cookie
header has changed between Jetty 11.0.24 (same as Jetty 9.4.54), and Jetty 12.0.16.When using Apache HTTP Client 4.5.14 (the latest 4.x.x version at the time of writing), a warning is logged as it is unable to parse the Set-Cookie header from Jetty 12.0.16, and the cookie is ignored. The exception is raised on line 64 of
org.apache.http.impl.cookie.BasicExpiresHandler
in theparse(SetCookie, String)
method, see: https://github.com/apache/httpcomponents-client/blob/rel/v4.5.14/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java#L64.How to reproduce?
When using either Jetty 9, 11, and 12 I have the
org.eclipse.jetty.server.HttpConfiguration#responseCookieCompliance
parameter set toorg.eclipse.jetty.http.CookieCompliance#RFC6265
.The response header generated by Jetty 11.0.24 (same as Jetty 9.4.54) looks like:
However, the response header generated by Jetty 12.0.16 looks like:
Note that the difference is
07
vs7
in theExpires
parameter.Whilst RFC6265 allows either of those formulations, it seems a shame that upgrading Jetty from version 11 to version 12 breaks client applications (that use Cookies) that are using the Apache HTTP Client.
There is a workaround which is to update any client code to modify the default configuration used by Apache HTTP Client so that it uses
CookieSpecs.STANDARD
instead ofCookieSpecs.DEFAULT
. As an example of achieving that, you can change client code that is like:to this:
The text was updated successfully, but these errors were encountered: