Support PyPI Simple API JSON responses - #290
Open
andrew wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds PEP 691-style JSON content negotiation support to the PyPI Simple API endpoints served by the proxy, while preserving the legacy HTML default and ensuring cached representations are separated by negotiated media type.
Changes:
- Selects an upstream Simple API representation based on the incoming
Acceptheader (JSON/vendor HTML/legacy HTML) and addsVary: Acceptto responses. - Rewrites Simple API JSON responses to proxy file URLs and applies cooldown filtering in the JSON representation.
- Adds/extends test coverage for negotiation behavior, cache separation, and cooldown behavior for Simple JSON.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/handler/pypi.go | Implements Simple API content negotiation, Vary: Accept, representation-specific caching, and Simple JSON rewriting. |
| internal/handler/pypi_test.go | Adds tests for representation selection, JSON negotiation, caching separation, and JSON cooldown filtering. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+167
to
+171
| switch mediaType { | ||
| case pypiSimpleJSON, pypiSimpleLatestJSON: | ||
| update(pypiSimpleJSON, quality, pypiExactSpecificity) | ||
| case pypiSimpleHTML, pypiSimpleLatestHTML: | ||
| update(pypiSimpleHTML, quality, pypiExactSpecificity) |
Comment on lines
+55
to
+58
| {"uv prefers json", uvPyPIAccept, pypiSimpleJSON}, | ||
| {"json only", pypiSimpleJSON, pypiSimpleJSON}, | ||
| {"latest json", pypiSimpleLatestJSON, pypiSimpleJSON}, | ||
| {"vendor html", pypiSimpleHTML, pypiSimpleHTML}, |
|
Looks good - tested with a local build. Thank you so much! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds JSON content negotiation to the PyPI Simple API project list and package endpoints while keeping the legacy HTML default.
Rewrites JSON file URLs through the proxy, preserves upload timestamps, and isolates cached HTML and JSON representations. This allows
uv exclude-newerto resolve packages through the proxy.Fixes #282