Skip to content

Commit 50a0624

Browse files
author
Noah Gorny
committed
session: Cache http requests to trusted hosts
1 parent 0de0b8d commit 50a0624

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

news/9498.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

src/pip/_internal/network/session.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,15 @@ def add_trusted_host(
358358
if host_port not in self.pip_trusted_origins:
359359
self.pip_trusted_origins.append(host_port)
360360

361+
self.mount(
362+
build_url_from_netloc(host, scheme="http") + "/", self._trusted_host_adapter
363+
)
361364
self.mount(build_url_from_netloc(host) + "/", self._trusted_host_adapter)
362365
if not host_port[1]:
366+
self.mount(
367+
build_url_from_netloc(host, scheme="http") + ":",
368+
self._trusted_host_adapter,
369+
)
363370
# Mount wildcard ports for the same host.
364371
self.mount(build_url_from_netloc(host) + ":", self._trusted_host_adapter)
365372

0 commit comments

Comments
 (0)