mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
catch ConnectionError on HEAD
This commit is contained in:
parent
84d4a5b97a
commit
57c866caf1
@ -26,7 +26,7 @@ from urllib.parse import unquote, urlparse
|
||||
from docutils import nodes
|
||||
from docutils.nodes import Element
|
||||
from requests import Response
|
||||
from requests.exceptions import HTTPError, TooManyRedirects
|
||||
from requests.exceptions import HTTPError, TooManyRedirects, ConnectionError
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.builders.dummy import DummyBuilder
|
||||
@ -460,7 +460,7 @@ class HyperlinkAvailabilityCheckWorker(Thread):
|
||||
config=self.config, auth=auth_info,
|
||||
**kwargs)
|
||||
response.raise_for_status()
|
||||
except (HTTPError, TooManyRedirects) as err:
|
||||
except (HTTPError, TooManyRedirects, ConnectionError) as err:
|
||||
if isinstance(err, HTTPError) and err.response.status_code == 429:
|
||||
raise
|
||||
# retry with GET request if that fails, some servers
|
||||
|
@ -579,16 +579,6 @@ def test_limit_rate_bails_out_after_waiting_max_time(app):
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-connection-error-on-http-head', freshenv=True)
|
||||
def test_get_after_head_raises_connection_error(app):
|
||||
class InternalServerErrorHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_error(500, "Internal Server Error")
|
||||
|
||||
with http_server(InternalServerErrorHandler):
|
||||
app.build()
|
||||
app.build()
|
||||
content = (app.outdir / 'output.txt').read_text()
|
||||
assert "broken" not in content
|
||||
# assert content == (
|
||||
# "index.rst:1: [broken] http://localhost:7777/#anchor: "
|
||||
# "500 Server Error: Internal Server Error "
|
||||
# "for url: http://localhost:7777/\n"
|
||||
# )
|
||||
assert not content
|
||||
|
Loading…
Reference in New Issue
Block a user