fix requests session stream
This commit is contained in:
parent
5bcd90c569
commit
2ee477c35e
@ -59,7 +59,8 @@ class RequestUtils:
|
|||||||
headers=self._headers,
|
headers=self._headers,
|
||||||
proxies=self._proxies,
|
proxies=self._proxies,
|
||||||
timeout=self._timeout,
|
timeout=self._timeout,
|
||||||
json=json)
|
json=json,
|
||||||
|
stream=False)
|
||||||
else:
|
else:
|
||||||
return requests.post(url,
|
return requests.post(url,
|
||||||
data=data,
|
data=data,
|
||||||
@ -67,7 +68,8 @@ class RequestUtils:
|
|||||||
headers=self._headers,
|
headers=self._headers,
|
||||||
proxies=self._proxies,
|
proxies=self._proxies,
|
||||||
timeout=self._timeout,
|
timeout=self._timeout,
|
||||||
json=json)
|
json=json,
|
||||||
|
stream=False)
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -109,7 +111,8 @@ class RequestUtils:
|
|||||||
proxies=self._proxies,
|
proxies=self._proxies,
|
||||||
cookies=self._cookies,
|
cookies=self._cookies,
|
||||||
timeout=self._timeout,
|
timeout=self._timeout,
|
||||||
allow_redirects=allow_redirects)
|
allow_redirects=allow_redirects,
|
||||||
|
stream=False)
|
||||||
else:
|
else:
|
||||||
return requests.get(url,
|
return requests.get(url,
|
||||||
params=params,
|
params=params,
|
||||||
@ -120,7 +123,8 @@ class RequestUtils:
|
|||||||
proxies=self._proxies,
|
proxies=self._proxies,
|
||||||
cookies=self._cookies,
|
cookies=self._cookies,
|
||||||
timeout=self._timeout,
|
timeout=self._timeout,
|
||||||
allow_redirects=allow_redirects)
|
allow_redirects=allow_redirects,
|
||||||
|
stream=False)
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise requests.exceptions.RequestException
|
raise requests.exceptions.RequestException
|
||||||
@ -129,7 +133,8 @@ class RequestUtils:
|
|||||||
def post_res(self, url: str, data: Any = None, params: dict = None,
|
def post_res(self, url: str, data: Any = None, params: dict = None,
|
||||||
allow_redirects: bool = True,
|
allow_redirects: bool = True,
|
||||||
files: Any = None,
|
files: Any = None,
|
||||||
json: dict = None) -> Optional[Response]:
|
json: dict = None,
|
||||||
|
raise_exception: bool = False) -> Optional[Response]:
|
||||||
try:
|
try:
|
||||||
if self._session:
|
if self._session:
|
||||||
return self._session.post(url,
|
return self._session.post(url,
|
||||||
@ -142,7 +147,8 @@ class RequestUtils:
|
|||||||
timeout=self._timeout,
|
timeout=self._timeout,
|
||||||
allow_redirects=allow_redirects,
|
allow_redirects=allow_redirects,
|
||||||
files=files,
|
files=files,
|
||||||
json=json)
|
json=json,
|
||||||
|
stream=False)
|
||||||
else:
|
else:
|
||||||
return requests.post(url,
|
return requests.post(url,
|
||||||
data=data,
|
data=data,
|
||||||
@ -154,8 +160,11 @@ class RequestUtils:
|
|||||||
timeout=self._timeout,
|
timeout=self._timeout,
|
||||||
allow_redirects=allow_redirects,
|
allow_redirects=allow_redirects,
|
||||||
files=files,
|
files=files,
|
||||||
json=json)
|
json=json,
|
||||||
|
stream=False)
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
|
if raise_exception:
|
||||||
|
raise requests.exceptions.RequestException
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user