diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 40e54a8d76a..6b1ef0a20e5 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -108,9 +108,7 @@ def init(self) -> None: self.workers.append(thread) def check_thread(self) -> None: - kwargs = { - 'allow_redirects': True, - } # type: Dict + kwargs = {} if self.app.config.linkcheck_timeout: kwargs['timeout'] = self.app.config.linkcheck_timeout @@ -171,8 +169,9 @@ def check_uri() -> Tuple[str, str, int]: try: # try a HEAD request first, which should be easier on # the server and the network - response = requests.head(req_url, config=self.app.config, - auth=auth_info, **kwargs) + response = requests.head(req_url, allow_redirects=True, + config=self.app.config, auth=auth_info, + **kwargs) response.raise_for_status() except HTTPError: # retry with GET request if that fails, some servers