slight impl change

Authored by: bashonly
This commit is contained in:
bashonly 2024-04-22 17:41:20 -05:00
parent 64d4c4ba72
commit 3b48105b8c
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0
3 changed files with 5 additions and 3 deletions

View File

@ -81,7 +81,7 @@ def close(self):
class CurlCFFIResponseAdapter(ImpersonateResponse):
fp: CurlCFFIResponseReader
def __init__(self, response: curl_cffi.requests.Response, impersonate: ImpersonateTarget):
def __init__(self, response: curl_cffi.requests.Response, impersonate: ImpersonateTarget | None):
super().__init__(
fp=CurlCFFIResponseReader(response),
headers=response.headers,

View File

@ -517,6 +517,7 @@ def __init__(
self.reason = reason or HTTPStatus(status).phrase
except ValueError:
self.reason = None
self.extras = {}
def readable(self):
return self.fp.readable()

View File

@ -65,9 +65,10 @@ class ImpersonateResponse(Response):
Parameters:
@param impersonate: the ImpersonateTarget used in the originating Request.
"""
def __init__(self, *args, impersonate: ImpersonateTarget, **kwargs):
def __init__(self, *args, impersonate: ImpersonateTarget | None, **kwargs):
super().__init__(*args, **kwargs)
self.impersonate = impersonate
if impersonate is not None:
self.extras['impersonate'] = impersonate
class ImpersonateRequestHandler(RequestHandler, ABC):