Drop RedirectLoop exception (#819)
* drop RedirectLoop exception * tests is package to allow run it easly * bring back test for redirect loop
This commit is contained in:
parent
db33c071e1
commit
efe9f61bc2
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,3 +8,5 @@ site/
|
||||
*.egg-info/
|
||||
venv*/
|
||||
.python-version
|
||||
build/
|
||||
dist/
|
||||
|
||||
@ -18,7 +18,6 @@ from ._exceptions import (
|
||||
ProtocolError,
|
||||
ProxyError,
|
||||
ReadTimeout,
|
||||
RedirectLoop,
|
||||
RequestBodyUnavailable,
|
||||
RequestNotRead,
|
||||
ResponseClosed,
|
||||
@ -66,7 +65,6 @@ __all__ = [
|
||||
"PoolTimeout",
|
||||
"ProtocolError",
|
||||
"ReadTimeout",
|
||||
"RedirectLoop",
|
||||
"RequestBodyUnavailable",
|
||||
"ResponseClosed",
|
||||
"ResponseNotRead",
|
||||
|
||||
@ -27,13 +27,7 @@ from ._dispatch.connection_pool import ConnectionPool
|
||||
from ._dispatch.proxy_http import HTTPProxy
|
||||
from ._dispatch.urllib3 import URLLib3Dispatcher
|
||||
from ._dispatch.wsgi import WSGIDispatch
|
||||
from ._exceptions import (
|
||||
HTTPError,
|
||||
InvalidURL,
|
||||
RedirectLoop,
|
||||
RequestBodyUnavailable,
|
||||
TooManyRedirects,
|
||||
)
|
||||
from ._exceptions import HTTPError, InvalidURL, RequestBodyUnavailable, TooManyRedirects
|
||||
from ._models import (
|
||||
URL,
|
||||
Cookies,
|
||||
@ -615,9 +609,6 @@ class Client(BaseClient):
|
||||
while True:
|
||||
if len(history) > self.max_redirects:
|
||||
raise TooManyRedirects()
|
||||
urls = ((resp.request.method, resp.url) for resp in history)
|
||||
if (request.method, request.url) in urls:
|
||||
raise RedirectLoop()
|
||||
|
||||
response = self.send_handling_auth(
|
||||
request, auth=auth, timeout=timeout, history=history
|
||||
@ -1142,9 +1133,6 @@ class AsyncClient(BaseClient):
|
||||
while True:
|
||||
if len(history) > self.max_redirects:
|
||||
raise TooManyRedirects()
|
||||
urls = ((resp.request.method, resp.url) for resp in history)
|
||||
if (request.method, request.url) in urls:
|
||||
raise RedirectLoop()
|
||||
|
||||
response = await self.send_handling_auth(
|
||||
request, auth=auth, timeout=timeout, history=history
|
||||
|
||||
@ -101,12 +101,6 @@ class TooManyRedirects(RedirectError):
|
||||
"""
|
||||
|
||||
|
||||
class RedirectLoop(RedirectError):
|
||||
"""
|
||||
Infinite redirect loop.
|
||||
"""
|
||||
|
||||
|
||||
class NotRedirectResponse(RedirectError):
|
||||
"""
|
||||
Response was not a redirect response.
|
||||
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@ -7,7 +7,6 @@ from httpx import (
|
||||
URL,
|
||||
AsyncClient,
|
||||
NotRedirectResponse,
|
||||
RedirectLoop,
|
||||
Request,
|
||||
RequestBodyUnavailable,
|
||||
Response,
|
||||
@ -245,20 +244,10 @@ async def test_too_many_redirects_calling_next():
|
||||
@pytest.mark.usefixtures("async_environment")
|
||||
async def test_redirect_loop():
|
||||
client = AsyncClient(dispatch=MockDispatch())
|
||||
with pytest.raises(RedirectLoop):
|
||||
with pytest.raises(TooManyRedirects):
|
||||
await client.get("https://example.org/redirect_loop")
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("async_environment")
|
||||
async def test_redirect_loop_calling_next():
|
||||
client = AsyncClient(dispatch=MockDispatch())
|
||||
url = "https://example.org/redirect_loop"
|
||||
response = await client.get(url, allow_redirects=False)
|
||||
with pytest.raises(RedirectLoop):
|
||||
while response.is_redirect:
|
||||
response = await response.anext()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("async_environment")
|
||||
async def test_cross_domain_redirect():
|
||||
client = AsyncClient(dispatch=MockDispatch())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user