Skip to content

Add conditional-request support to PyPI metadata APIs - #1341

Open
dkliban wants to merge 1 commit into
pulp:mainfrom
dkliban:1338-conditional-requests
Open

Add conditional-request support to PyPI metadata APIs#1341
dkliban wants to merge 1 commit into
pulp:mainfrom
dkliban:1338-conditional-requests

Conversation

@dkliban

@dkliban dkliban commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Add Last-Modified / If-Modified-Since conditional request support to the Simple API and JSON Metadata API for Akamai Centralized Authorization. Also adds ETag, Cache-Control, and If-None-Match support to the JSON Metadata API which previously had none.

Changes:

  • Extract _get_repo_version() helper to share repo version resolution between _etag_func and new _last_modified_func
  • Add last_modified_func=_last_modified_func to @condition decorators on SimpleView.list and SimpleView.retrieve
  • Add @condition(etag_func=_etag_func, last_modified_func=_last_modified_func) and @cache_control(max_age=900, public=True) to MetadataView.retrieve

Security: Authorization is checked before conditional request handling because DRF's initial() (permissions) runs before the view method where @condition operates.

Closes: #1338

Test plan

  • test_simple_last_modified_header — Last-Modified present on Simple API responses
  • test_simple_if_modified_since_304 — If-Modified-Since with matching timestamp returns 304
  • test_simple_if_modified_since_old_timestamp_200 — old timestamp returns 200
  • test_metadata_conditional_request_headers — ETag, Last-Modified, Cache-Control on metadata
  • test_metadata_etag_conditional_request — If-None-Match 304/200
  • test_metadata_if_modified_since_304 — If-Modified-Since 304
  • test_metadata_if_modified_since_old_timestamp_200 — old timestamp returns 200
  • All 4 existing cache tests still pass

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>
@jobselko

Copy link
Copy Markdown
Member

@dkliban Please tag me as a reviewer once this is ready (maybe it already is?)

@dkliban
dkliban requested a review from jobselko August 20, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add conditional-request support (ETag + Last-Modified) to PyPI metadata APIs for Akamai Centralized Authorization

2 participants