Skip to content

Commit

Permalink
Apply tls_verify and tls_cacerts to ImageDownloader (sphinx-doc#11716)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <[email protected]>
  • Loading branch information
ntouran and AA-Turner authored Jan 8, 2024
1 parent db9e476 commit 2d1b943
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Bugs fixed
* #11675: Fix rendering of progression bars in environments that do not support
ANSI control sequences.
Patch by Bénédikt Tran.
* #11715: Apply ``tls_verify`` and ``tls_cacerts`` config to
``ImageDownloader``.
Patch by Nick Touran.

Testing
-------
Expand Down
7 changes: 6 additions & 1 deletion sphinx/transforms/post_transforms/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ def handle(self, node: nodes.image) -> None:
timestamp: float = ceil(os.stat(path).st_mtime)
headers['If-Modified-Since'] = epoch_to_rfc1123(timestamp)

r = requests.get(node['uri'], headers=headers)
config = self.app.config
r = requests.get(
node['uri'], headers=headers,
_user_agent=config.user_agent,
_tls_info=(config.tls_verify, config.tls_cacerts),
)
if r.status_code >= 400:
logger.warning(__('Could not fetch remote image: %s [%d]') %
(node['uri'], r.status_code))
Expand Down

0 comments on commit 2d1b943

Please sign in to comment.