Skip to content

Commit

Permalink
linkcheck builder: close streamed HTTP response objects when no respo…
Browse files Browse the repository at this point in the history
…nse-content reads are required
  • Loading branch information
jayaddison committed Apr 11, 2023
1 parent 2c83af0 commit f538440
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sphinx/builders/linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def check_uri() -> tuple[str, str, int]:
# Read the whole document and see if #anchor exists
response = requests.get(req_url, stream=True, config=self.config,
auth=auth_info, **kwargs)
response.close() # no HTTP body reads required; close the response
response.raise_for_status()
found = check_anchor(response, unquote(anchor))

Expand All @@ -341,6 +342,7 @@ def check_uri() -> tuple[str, str, int]:
response = requests.get(req_url, stream=True,
config=self.config,
auth=auth_info, **kwargs)
response.close() # no HTTP body reads required; close the response
response.raise_for_status()
except HTTPError as err:
if err.response.status_code == 401:
Expand Down

0 comments on commit f538440

Please sign in to comment.