Use custom Response on FlareRequest
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2022-12-21 16:46:50 +00:00
parent cb5ecf9a29
commit 068aebdaaf

View File

@ -1,5 +1,5 @@
from urllib import parse from urllib import parse
from requests import RequestException, Session, post from requests import RequestException, Response, Session, post
from .config import CLOUDPROXY_ENDPOINT, REQUESTS_TIMEOUT from .config import CLOUDPROXY_ENDPOINT, REQUESTS_TIMEOUT
@ -35,13 +35,16 @@ class FlareRequests(Session):
solution = response.json() solution = response.json()
if "solution" in solution: if "solution" in solution:
response.status_code = solution["solution"]["status"] resolved = Response()
response.headers = solution["solution"]["headers"]
response.raw = solution["solution"]["response"]
response.url = url
response.cookies = solution["solution"]["cookies"]
return response resolved.raw = solution["solution"]["response"]
resolved.status_code = solution["solution"]["status"]
resolved.headers = solution["solution"]["headers"]
resolved.url = url
resolved.reason = solution["status"]
resolved.cookies = solution["solution"]["cookies"]
return resolved
raise RequestException(response) raise RequestException(response)
except RequestException: except RequestException: