Skip to content

Commit

Permalink
session: Cache http requests to trusted hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Gorny committed Jan 23, 2021
1 parent b944419 commit 38b1d1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/9498.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cache http responses from trusted hosts.
8 changes: 8 additions & 0 deletions src/pip/_internal/network/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38b1d1c

Please sign in to comment.