httpclient: add follow_redirects argument

This commit is contained in:
lilydjwg 2021-01-28 17:47:46 +08:00
parent 2e069fe1c7
commit 9c2d2a39d7
4 changed files with 9 additions and 0 deletions

View File

@ -32,12 +32,14 @@ class AiohttpSession(BaseSession):
method: str,
proxy: Optional[str] = None,
headers: Dict[str, str] = {},
follow_redirects: bool = True,
params = (),
json = None,
) -> Response:
kwargs = {
'headers': headers,
'params': params,
'allow_redirects': follow_redirects,
}
if proxy is not None:

View File

@ -58,6 +58,7 @@ class BaseSession:
self, url: str, *,
method: str,
headers: Dict[str, str] = {},
follow_redirects: bool = True,
params = (),
json = None,
) -> Response:
@ -75,6 +76,7 @@ class BaseSession:
method = method,
headers = headers,
params = params,
follow_redirects = follow_redirects,
json = json,
proxy = p or None,
)
@ -93,6 +95,7 @@ class BaseSession:
method: str,
proxy: Optional[str] = None,
headers: Dict[str, str] = {},
follow_redirects: bool = True,
params = (),
json = None,
) -> Response:

View File

@ -24,6 +24,7 @@ class HttpxSession(BaseSession):
method: str,
proxy: Optional[str] = None,
headers: Dict[str, str] = {},
follow_redirects: bool = True,
params = (),
json = None,
) -> Response:
@ -40,6 +41,7 @@ class HttpxSession(BaseSession):
r = await client.request(
method, url, json = json,
headers = headers,
allow_redirects = follow_redirects,
params = params,
)
err_cls: Optional[type] = None

View File

@ -49,6 +49,7 @@ class TornadoSession(BaseSession):
method: str,
proxy: Optional[str] = None,
headers: Dict[str, str] = {},
follow_redirects: bool = True,
params = (),
json = None,
) -> Response:
@ -56,6 +57,7 @@ class TornadoSession(BaseSession):
'method': method,
'headers': headers,
'request_timeout': self.timeout,
'follow_redirects': follow_redirects,
}
if json: