Skip to content

refactor(core): format cached HTTP dates with httpdate - #1132

Open
jbruinink wants to merge 1 commit into
cloudflare:mainfrom
jbruinink:fix/http-date-without-chrono
Open

jbruinink wants to merge 1 commit into
cloudflare:mainfrom
jbruinink:fix/http-date-without-chrono

Conversation

@jbruinink

Copy link
Copy Markdown

Closes #1131.

pingora-core uses Chrono only for HTTP Date header formatting, while already depending on httpdate. Reuse httpdate::fmt_http_date and remove the direct Chrono dependency without changing the thread-local, per-second header cache or adding dependencies. This also removes that direct source of the Chrono maintenance advisory (RUSTSEC-2026-0543).

Formatting is identical from the Unix epoch through 9999-12-31T23:59:59Z. Because httpdate panics for later dates, clamp those values to the last four-digit HTTP date. This deliberately replaces Chrono's extended-year output for out-of-range clocks; existing pre-epoch clock handling is unchanged. Formatting still produces one temporary String per cache refresh, with no additional allocation on cache hits.

Replace the wall-clock-dependent cache assertion with deterministic coverage of same-second allocation reuse, second rollover and backward clock adjustment. Add epoch, RFC example, leap-day/century, upper-bound and out-of-range cases.

Validation on macOS/aarch64 with Rust 1.93.1:

  • cargo fmt --all -- --check and git diff --check pass.
  • cargo test -p pingora-core --lib protocols::http::date --no-default-features: 3 passed.
  • cargo test -p pingora-core --lib protocols::http --no-default-features: 521 passed, 1 ignored.
  • A separate, temporary comparison against Chrono 0.4.45 matched 6,124,994 timestamps: the first and last second of every day from 1970 through 9999, plus every second across the 2000 leap-day transition. Chrono is not retained as a test dependency.
  • cargo tree -p pingora-core --edges normal --no-default-features contains httpdate and no Chrono. Optional features may still bring their own transitive dependencies.

The full workspace/TLS matrix is left to upstream CI.

Reuse the existing HTTP date formatter and remove the direct Chrono dependency. Preserve per-second caching and clamp dates beyond the four-digit year range to avoid formatter panics.
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.

Replace Chrono in cached HTTP Date formatting with existing httpdate dependency

1 participant