-
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
Introduce new HttpDateTime class for parsing obsolete Date formats in HTTP and Cookie #11648
Comments
Your expires format is invalid per Cookie spec. https://datatracker.ietf.org/doc/html/rfc6265 # you have
expires=Fri, 11-Apr-2025 20:23:36 GMT;
# it should be
Expires=Fri, 11 Apr 2025 20:23:36 GMT; There are 2 things.
|
Of note, if you used that Expires format on a web browser like Chrome or Firefox you'll have one of two things happen.
Older browsers tended to ignore the Attribute, leaving the reset of the |
By the principle of "strict in what you generate and forgiving in what you parse", should be perhaps not throw for a badly formed expires date? I.e. we should either ignore the attribute or the whole cookie, but not fail entirely. |
Hi Masters: |
Looking at various specs for Date / Time, the spec you are using is looking kind like RFC850. The RFC850 format was deprecated and called obsolete in 1987, replaced by RFC1036. That being said, the obsolete date format is still listed on the HTTP spec RFC9110. To support this properly, we would need to add additional parser formats for ...
This will cause quite a hit on performance. |
Consider also that JDK has I would not try to be compliant with specifications that are from 1983, a whopping 41 years ago. |
I have the same problem. Cloudflare send cookies in this format.
I would have expected that such a big service like Cloudflare would be sending cookies in the correct format. Is there any workaround? |
I'd be surprised if it's CloudFlare. |
They are cookies from cloudflare. I have tested |
@martin8877 have you contacted CloudFlare to tell them about this issue? If so, can you link their issue here? |
The cloudflare rest API returns this awful format
|
Opened PR #11658 as a possible solution. |
Set-Cookie
Expires
attribute does not support obsolete Date formats
+ Introduces HTTP (and Cookie) Date/Time parsing according to spec algorithms. + Introduces formatting according to spec mandated preferred RFC 1123 format. + Deprecate DateParser
+ Introduces HTTP (and Cookie) Date/Time parsing according to spec algorithms. + Introduces formatting according to spec mandated preferred RFC 1123 format. + Deprecate DateParser
Set-Cookie
Expires
attribute does not support obsolete Date formats
Jetty version(s)
12
Jetty Environment
core
Java version/vendor
(use: java -version)
Oracle jdk 17
OS type/version
RHE 9
Description
2024-04-11T20:23:36.876Z DEBUG 1 --- [ent@3c5044fa-40] o.e.jetty.client.transport.HttpReceiver : Notifying header Set-Cookie: LSKey-c$CookieConsentPolicy=0:1; path=/; expires=Fri, 11-Apr-2025 20:23:36 GMT; Max-Age=31536000; secure
2024-04-11T20:23:36.876Z DEBUG 1 --- [ent@3c5044fa-40] o.e.jetty.http.RFC6265SetCookieParser : could not set attribute expires=Fri
java.time.format.DateTimeParseException: Text 'Fri' could not be parsed at index 0
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2052)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1954)
at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:600)
at org.eclipse.jetty.http.HttpCookie.parseExpires(HttpCookie.java:906)
at org.eclipse.jetty.http.HttpCookie$Builder.attribute(HttpCookie.java:542)
at org.eclipse.jetty.http.RFC6265SetCookieParser.setAttribute(RFC6265SetCookieParser.java:200)
at org.eclipse.jetty.http.RFC6265SetCookieParser.parse(RFC6265SetCookieParser.java:186)
at org.cometd.client.transport.HttpClientTransport.lambda$storeCookies$0(HttpClientTransport.java:60)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.cometd.client.transport.HttpClientTransport.lambda$storeCookies$1(HttpClientTransport.java:59)
at java.base/java.util.Map.forEach(Map.java:713)
at org.cometd.client.transport.HttpClientTransport.storeCookies(HttpClientTransport.java:57)
at org.cometd.client.http.jetty.JettyHttpClientTransport.access$000(JettyHttpClientTransport.java:52)
at org.cometd.client.http.jetty.JettyHttpClientTransport$ResponseListener.onHeader(JettyHttpClientTransport.java:239)
at org.eclipse.jetty.client.transport.ResponseListeners.notifyHeader(ResponseListeners.java:129)
at org.eclipse.jetty.client.transport.ResponseListeners.notifyHeader(ResponseListeners.java:121)
at org.eclipse.jetty.client.transport.HttpReceiver.lambda$responseHeader$1(HttpReceiver.java:200)
at org.eclipse.jetty.util.thread.SerializedInvoker$Link.run(SerializedInvoker.java:191)
at org.eclipse.jetty.util.thread.SerializedInvoker.run(SerializedInvoker.java:117)
at org.eclipse.jetty.client.transport.HttpReceiver.responseHeader(HttpReceiver.java:189)
at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.parsedHeader(HttpReceiverOverHTTP.java:419)
at org.eclipse.jetty.http.HttpParser.parsedHeader(HttpParser.java:1109)
at org.eclipse.jetty.http.HttpParser.parseFields(HttpParser.java:1268)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1543)
at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:312)
at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.parseAndFill(HttpReceiverOverHTTP.java:250)
at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:76)
at org.eclipse.jetty.client.transport.internal.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:90)
at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:194)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
at org.eclipse.jetty.io.ssl.SslConnection$SslEndPoint.onFillable(SslConnection.java:555)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:374)
at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:147)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:478)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:441)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:201)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:311)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:979)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1209)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1164)
at java.base/java.lang.Thread.run(Thread.java:842)
How to reproduce?
The text was updated successfully, but these errors were encountered: