Skip to content

Commit

Permalink
uv-client: switch to RFC 9110 compatible format
Browse files Browse the repository at this point in the history
This still utilizes the RFC 2822 datetime formatter, but utilizes new
methods [added in jiff 0.1.14] to emit timestamps in a format strictly
compatible with RFC 9110.

It seems like most HTTP servers were pretty flexible and supported RFC
2822 datetime formats, but #8747 shows at least one case where that
isn't true. Given that the [MDN docs prescribe RFC 9110], we defer to
them.

Fixes #8747

[added in jiff 0.1.14]: BurntSushi/jiff#154
[MDN docs prescribe RFC 9110]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
  • Loading branch information
BurntSushi committed Nov 1, 2024
1 parent bf8436c commit ea614fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ indexmap = { version = "2.5.0" }
indicatif = { version = "0.17.8" }
indoc = { version = "2.0.5" }
itertools = { version = "0.13.0" }
jiff = { version = "0.1.13", features = ["serde"] }
jiff = { version = "0.1.14", features = ["serde"] }
junction = { version = "1.2.0" }
krata-tokio-tar = { version = "0.4.2" }
mailparse = { version = "0.15.0" }
Expand Down
6 changes: 2 additions & 4 deletions crates/uv-client/src/httpcache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,11 +1381,9 @@ fn unix_timestamp_to_rfc2822(seconds: u64) -> Option<String> {
use jiff::fmt::rfc2822::DateTimePrinter;

unix_timestamp_to_datetime(seconds).and_then(|timestamp| {
let mut buf = String::new();
DateTimePrinter::new()
.print_timestamp(&timestamp, &mut buf)
.ok()?;
Some(buf)
.timestamp_to_rfc9110_string(&timestamp)
.ok()
})
}

Expand Down

0 comments on commit ea614fa

Please sign in to comment.