Skip to content

Allow Request#getDateHeader to parse dates in RFC 9651 Structured Field Values format - #1054

Open
sabberworm wants to merge 3 commits into
apache:mainfrom
sabberworm:fix/parse-rfc9651-dates
Open

Allow Request#getDateHeader to parse dates in RFC 9651 Structured Field Values format#1054
sabberworm wants to merge 3 commits into
apache:mainfrom
sabberworm:fix/parse-rfc9651-dates

Conversation

@sabberworm

Copy link
Copy Markdown

RFC 9651 (Structured Field Values for HTTP) defines formats for header values of specific types. The format it uses for dates is @«timestamp», which is different from other date headers.

This PR aims to support the date header format from RFC 9651 in org.apache.catalina.connector.Request#getDateHeader(String).

Comment thread java/org/apache/tomcat/util/http/FastHttpDateFormat.java
Comment thread java/org/apache/tomcat/util/http/FastHttpDateFormat.java Outdated
}
date = httpParseFormats[i].tryParseDate(value);
}
updateParseCache(value, Long.valueOf(date));

@sabberworm sabberworm Aug 27, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is also called for values that failed to parse. Not sure if that’s better or worse. IMHO it makes sense to also cache these, since they’re the most expensive to calculate as they have to be tried (and rejected) by all the parsers.

* Tries to parse the given string as a date and returns it as a timestamp.
*
* @param dateString the string representation of the date trying to be parsed
* @return the number of *milli*seconds since January 1, 1970, 00:00:00 GMT or -1 if parsing failed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return the number of *milli*seconds since January 1, 1970, 00:00:00 GMT or -1 if parsing failed
* @return the number of <em>milli</em>seconds since January 1, 1970, 00:00:00 GMT or -1 if parsing failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant