summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)