From 9c2d2a39d7d0cdffdfb13cac2fffd3d5a77b4aaa Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Thu, 28 Jan 2021 17:47:46 +0800 Subject: [PATCH] httpclient: add follow_redirects argument --- nvchecker/httpclient/aiohttp_httpclient.py | 2 ++ nvchecker/httpclient/base.py | 3 +++ nvchecker/httpclient/httpx_httpclient.py | 2 ++ nvchecker/httpclient/tornado_httpclient.py | 2 ++ 4 files changed, 9 insertions(+) diff --git a/nvchecker/httpclient/aiohttp_httpclient.py b/nvchecker/httpclient/aiohttp_httpclient.py index 38ebde2..f908bb7 100644 --- a/nvchecker/httpclient/aiohttp_httpclient.py +++ b/nvchecker/httpclient/aiohttp_httpclient.py @@ -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: diff --git a/nvchecker/httpclient/base.py b/nvchecker/httpclient/base.py index b357e55..f4f6061 100644 --- a/nvchecker/httpclient/base.py +++ b/nvchecker/httpclient/base.py @@ -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: diff --git a/nvchecker/httpclient/httpx_httpclient.py b/nvchecker/httpclient/httpx_httpclient.py index 89c084f..063be2a 100644 --- a/nvchecker/httpclient/httpx_httpclient.py +++ b/nvchecker/httpclient/httpx_httpclient.py @@ -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 diff --git a/nvchecker/httpclient/tornado_httpclient.py b/nvchecker/httpclient/tornado_httpclient.py index 81d3e3d..9c9058a 100644 --- a/nvchecker/httpclient/tornado_httpclient.py +++ b/nvchecker/httpclient/tornado_httpclient.py @@ -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: