diff --git a/news/9498.feature.rst b/news/9498.feature.rst new file mode 100644 index 00000000000..bbaca4f98cc --- /dev/null +++ b/news/9498.feature.rst @@ -0,0 +1 @@ +Cache http responses from trusted hosts. diff --git a/src/pip/_internal/network/session.py b/src/pip/_internal/network/session.py index 5021b8eefaa..93bb8912479 100644 --- a/src/pip/_internal/network/session.py +++ b/src/pip/_internal/network/session.py @@ -327,12 +327,20 @@ def add_trusted_host(self, host, source=None, suppress_logging=False): 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]: # Mount wildcard ports for the same host. + self.mount( + build_url_from_netloc(host, scheme='http') + ':', + self._trusted_host_adapter + ) self.mount( build_url_from_netloc(host) + ':', self._trusted_host_adapter