Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if-modified-since header should use GMT instead of -0000 #8747

Closed
camper42 opened this issue Nov 1, 2024 · 4 comments · Fixed by #8752
Closed

if-modified-since header should use GMT instead of -0000 #8747

camper42 opened this issue Nov 1, 2024 · 4 comments · Fixed by #8752
Assignees
Labels
bug Something isn't working

Comments

@camper42
Copy link

camper42 commented Nov 1, 2024

  • command: uv lock -U uses our internal registry, backed by Tencent COS.
  • uv platform: macOS
  • uv version: uv 0.4.29 (Homebrew, 2024-10-30)

error log:

error: Failed to download `something==0.14.0`
  Caused by: Failed to fetch: `https://pypi.internal/api/package/something/something-0.14.0-py3-none-any.whl#sha256=ab3bae4f61c0ca8a72da6836610fd1256bd203420d7ec95be43afcc73512bcff`
  Caused by: HTTP status client error (400 Bad Request) for url (https://cos.tencent/our-bucket/packages/3751/something/something-0.14.0-py3-none-any.whl?Some_sig_params)

The issue is that COS reported: The If-Modified-Since you specified is not valid.

I checked the request header sent by UV, and it appears as follows: if-modified-since: Wed, 17 Jul 2024 03:39:18 -0000.

According to the MDN documentation, HTTP dates should always be expressed in GMT, not in local time.

Therefore, uv should adjust the header value to something like: if-modified-since: Wed, 17 Jul 2024 03:39:18 GMT.

@camper42
Copy link
Author

camper42 commented Nov 1, 2024

@BurntSushi
Copy link
Member

I responded here with a bit more on the datetime side of things.

This PR adds a new API to Jiff to make it easy to print RFC 9110 compatible timestamps. So once that's released, we just need to update uv to use that new API and I believe this should be fixed.

According to the MDN documentation, HTTP dates should always be expressed in GMT, not in local time.

One clarification here is that the existing format is not in local time. It is semantically equivalent to GMT. It's using -0000 to express that instead of GMT. But they are the same thing. Interestingly, RFC 2822/5322 considers GMT to be obsolete. But RFC 9110 requires it specifically.

(The other difference is that RFC 9110 requires a two digit day. This makes the value fixed length.)

BurntSushi added a commit that referenced this issue Nov 1, 2024
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
@camper42
Copy link
Author

camper42 commented Nov 1, 2024

One clarification here is that the existing format is not in local time.

I just copied the whole sentence, sorry for the ambiguity, I checked the time and the package was modified at the right time (Jul 17 11:39:18 2024 +0800).

Thanks for the quick fix, it's one of the reasons why I love uv!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants