kopia lustrzana https://github.com/jointakahe/takahe
Fix follow_redirects handling
rodzic
cd160050ac
commit
1dec02f89c
|
@ -222,14 +222,16 @@ class BaseClient(httpx._client.BaseClient):
|
||||||
|
|
||||||
|
|
||||||
class Client(BaseClient, httpx.Client):
|
class Client(BaseClient, httpx.Client):
|
||||||
def request(self, url: URLTypes, method: str, **params) -> httpx.Response:
|
def request(self, method: str, url: URLTypes, **params) -> httpx.Response:
|
||||||
"""
|
"""
|
||||||
Wraps some errors up nicer
|
Wraps some errors up nicer
|
||||||
"""
|
"""
|
||||||
|
if method.lower == "get":
|
||||||
|
if params["follow_redirects"] is httpx._client.USE_CLIENT_DEFAULT:
|
||||||
|
params["follow_redirects"] = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = super().request(
|
response = super().request(method, url, **params)
|
||||||
method, url, follow_redirects=method == "get", **params
|
|
||||||
)
|
|
||||||
except SSLError as invalid_cert:
|
except SSLError as invalid_cert:
|
||||||
# Not our problem if the other end doesn't have proper SSL
|
# Not our problem if the other end doesn't have proper SSL
|
||||||
logger.info("Invalid cert on %s %s", url, invalid_cert)
|
logger.info("Invalid cert on %s %s", url, invalid_cert)
|
||||||
|
|
Ładowanie…
Reference in New Issue