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

pip: disable cache for modified response #793

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkgs/fetchPipMetadata/filter-pypi-responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ def response(flow: http.HTTPFlow) -> None:
print(f"removing the following files form the API response:\n {badFiles}")
data["files"] = list(filter(keepFile, data["files"]))
flow.response.text = json.dumps(data)
# prevent the modified response from ending up in the pip cache
flow.response.headers["Vary"] = "*"
# See this comment in cachecontrol/controller.py in pip:
# https://tools.ietf.org/html/rfc7234#section-4.1:
# A Vary header field-value of "*" always fails to match.
# Storing such a response leads to a deserialization warning
# during cache lookup and is not allowed to ever be served,
# so storing it can be avoided.