uv-client: switch to RFC 9110 compatible format (#8752)

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]: https://github.com/BurntSushi/jiff/pull/154
[MDN docs prescribe RFC 9110]:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
This commit is contained in:
Andrew Gallant 2024-11-01 09:46:24 -04:00 committed by GitHub
parent f8291144c0
commit 049ccf7d77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 7 deletions

View file

@ -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()
})
}