Add conditional-request support to PyPI metadata APIs - #1341
Open
dkliban wants to merge 1 commit into
Open
Conversation
Add Last-Modified header and If-Modified-Since handling to SimpleView and MetadataView for Akamai Centralized Authorization. Add ETag, Cache-Control, and conditional request support to MetadataView which previously had none. Closes: pulp#1338 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
|
@dkliban Please tag me as a reviewer once this is ready (maybe it already is?) |
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.
Summary
Add
Last-Modified/If-Modified-Sinceconditional request support to the Simple API and JSON Metadata API for Akamai Centralized Authorization. Also addsETag,Cache-Control, andIf-None-Matchsupport to the JSON Metadata API which previously had none.Changes:
_get_repo_version()helper to share repo version resolution between_etag_funcand new_last_modified_funclast_modified_func=_last_modified_functo@conditiondecorators onSimpleView.listandSimpleView.retrieve@condition(etag_func=_etag_func, last_modified_func=_last_modified_func)and@cache_control(max_age=900, public=True)toMetadataView.retrieveSecurity: Authorization is checked before conditional request handling because DRF's
initial()(permissions) runs before the view method where@conditionoperates.Closes: #1338
Test plan
test_simple_last_modified_header— Last-Modified present on Simple API responsestest_simple_if_modified_since_304— If-Modified-Since with matching timestamp returns 304test_simple_if_modified_since_old_timestamp_200— old timestamp returns 200test_metadata_conditional_request_headers— ETag, Last-Modified, Cache-Control on metadatatest_metadata_etag_conditional_request— If-None-Match 304/200test_metadata_if_modified_since_304— If-Modified-Since 304test_metadata_if_modified_since_old_timestamp_200— old timestamp returns 200