-
Notifications
You must be signed in to change notification settings - Fork 3
Add CLI options for enhancing requests with HTTP headers #7
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be ideal to have some feedback on the upstream PR before merging this (in particular: I suspect that they might request a more limited feature), but it looks well tested and fairly isolated.
If Benjy or John are fine with landing it, I am.
I don't understand the purpose of this except as a hack around a misconfigured server. In other words, pip uses requests and installs a cache aware adapter that looks kosher: |
Hi @jsirois that's a good question. In fact it requires both client and server to be configured correctly, excerpt from pypa#8109 (comment):
That said, there's no rush. We can wait till pypa#8078 gets merged upstream. |
Thanks @wisechengyi. I guess I still don't believe that can be true. If it is true it means there is a semi-substantial amount of code in pip dedicated to caching for all HTTP requests (for both simple index requests and find-links requests), that's broken. Since the code is there, it should work. Having to manually add headers to make it work sounds broken. I'll carve out time to do my own experiments. |
The below change could be useful when experimenting against a http server instead of https server, as the http adapter will just ignore cache.
|
@wisechengyi is the HTTP case your case? If so, can your findlinks server be converted to HTTPS? |
Right, I experimented against a http server locally. On pip master, http won't be cached, but since I was able to use the diff above to get around it, I won't necessarily need a https server. |
I'm confused. In this PR you present a patch that allows working around non-caching. In your HTTP vs HTTPS comment you do the same. Either way, you're patching Pex's vendored pip to work around non-caching. What I'm trying to get at is, does caching actually work as things stand - no patches - if the find-links server is:
|
Sorry about the confusion.
The answer is no from my experiement, because max-age is always 0 in the request header (https://github.com/pypa/pip/blob/master/src/pip/_internal/index/collector.py#L152-L166), and pip needs max-age > 0 to turn on caching. |
Thanks Yi. I do not like what Pip did there with max-age, but that's not your problem and this gives us a fix for now. |
Cherry pick pypa#8078
Fixes: pypa#8109