summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Gorny <noah@gittabags.com>2021-01-23 22:42:59 +0200
committerNoah Gorny <noah@gittabags.com>2021-09-15 17:21:51 +0300
commit50a0624a9accb1ec4a93d8f2b1ef350fc76c2081 (patch)
treeb99c133018ed1db4c0519251786a0fcf7bf79f0d
parent0de0b8dd9f21642dc6d0e00bfa8913f4964b1706 (diff)
downloadpip-50a0624a9accb1ec4a93d8f2b1ef350fc76c2081.tar.gz
session: Cache http requests to trusted hosts
-rw-r--r--news/9498.feature.rst1
-rw-r--r--src/pip/_internal/network/session.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/news/9498.feature.rst b/news/9498.feature.rst
new file mode 100644
index 000000000..0682915e4
--- /dev/null
+++ b/news/9498.feature.rst
@@ -0,0 +1 @@
+If a host is explicitly specified as trusted by the user (via the --trusted-host option), cache HTTP responses from it in addition to HTTPS ones.
diff --git a/src/pip/_internal/network/session.py b/src/pip/_internal/network/session.py
index fe1cf717e..e2916ca81 100644
--- a/src/pip/_internal/network/session.py
+++ b/src/pip/_internal/network/session.py
@@ -358,8 +358,15 @@ class PipSession(requests.Session):
if host_port not in self.pip_trusted_origins:
self.pip_trusted_origins.append(host_port)
+ self.mount(
+ build_url_from_netloc(host, scheme="http") + "/", self._trusted_host_adapter
+ )
self.mount(build_url_from_netloc(host) + "/", self._trusted_host_adapter)
if not host_port[1]:
+ self.mount(
+ build_url_from_netloc(host, scheme="http") + ":",
+ self._trusted_host_adapter,
+ )
# Mount wildcard ports for the same host.
self.mount(build_url_from_netloc(host) + ":", self._trusted_host_adapter)