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

integrity: refine Accept header handling #17498

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

woodruffw
Copy link
Member

@woodruffw woodruffw commented Jan 24, 2025

This tweaks the Accept handling for this endpoint in the following ways:

  1. We no longer accept HTML mimetypes only to reject them later, since this results in a confused state between accept matching and the actual HTTP response
  2. We use the 'identity' marker to ensure an adequate fallback when the user doesn't explicitly specify Accept
  3. We now accept application/json, although this could be removed from the changeset

(NB: The main reason I added application/json is to ensure fallbacks/q-factor sorting works as expected.)

I've also added a bunch of parametrized tests to ensure that we handle various combinations/orders/q-values correctly.

See #17084.

@woodruffw woodruffw requested a review from a team as a code owner January 24, 2025 19:48
@woodruffw woodruffw self-assigned this Jan 24, 2025
warehouse/api/integrity.py Outdated Show resolved Hide resolved
Signed-off-by: William Woodruff <[email protected]>
warehouse/api/integrity.py Outdated Show resolved Hide resolved
Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw requested a review from di January 27, 2025 17:06
Signed-off-by: William Woodruff <[email protected]>
@di di merged commit 6afcba5 into pypi:main Jan 27, 2025
20 checks passed
@di di deleted the ww/integrity-better-accept branch January 27, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants