Invalid date format error when setting HTTP Date header in Vert.x
0 reputation · 17 May 2022, 18:51 UTC
When building a Vert.x HTTP application, developers must supply the Date header as an RFC‑1123 formatted string. Vert.x validates this value in HttpServerResponseImpl.putDateHeader and throws java.lang.IllegalArgumentException with the message "Invalid date format" if the string does not match the expected pattern. Because Vert.x does not provide a built‑in helper to convert java.time.ZonedDateTime (or OffsetDateTime) to the required format, developers must perform the conversion manually, which introduces the risk of malformed strings and timezone‑related exceptions.
The unresolved design decision is whether Vert.x should expose a utility method such as TimeTools.formatRfc1123(ZonedDateTime) to eliminate manual formatting and reduce the chance of the exception, while considering backward compatibility, Java version support, and handling of invalid zone IDs.
- Should Vert.x add a helper method to format
ZonedDateTimeas RFC‑1123 for HTTP headers? - What are the implications for existing applications and for Vert.x versions that still support Java 7?
- How should the helper behave when supplied with an unknown or invalid timezone identifier?