feat(Fetcher): Add the redirections history to Fetcher
Feature requested in #32
This commit is contained in:
@@ -72,6 +72,7 @@ class StaticEngine:
|
||||
headers=dict(response.headers),
|
||||
request_headers=dict(response.request.headers),
|
||||
method=response.request.method,
|
||||
history=[self._prepare_response(redirection) for redirection in response.history],
|
||||
**self.adaptor_arguments
|
||||
)
|
||||
|
||||
|
||||
@@ -85,13 +85,14 @@ class Response(Adaptor):
|
||||
"""This class is returned by all engines as a way to unify response type between different libraries."""
|
||||
|
||||
def __init__(self, url: str, text: str, body: bytes, status: int, reason: str, cookies: Dict, headers: Dict, request_headers: Dict,
|
||||
encoding: str = 'utf-8', method: str = 'GET', **adaptor_arguments: Dict):
|
||||
encoding: str = 'utf-8', method: str = 'GET', history: List = None, **adaptor_arguments: Dict):
|
||||
automatch_domain = adaptor_arguments.pop('automatch_domain', None)
|
||||
self.status = status
|
||||
self.reason = reason
|
||||
self.cookies = cookies
|
||||
self.headers = headers
|
||||
self.request_headers = request_headers
|
||||
self.history = history or []
|
||||
encoding = ResponseEncoding.get_value(encoding, text)
|
||||
super().__init__(text=text, body=body, url=automatch_domain or url, encoding=encoding, **adaptor_arguments)
|
||||
# For back-ward compatibility
|
||||
|
||||
Reference in New Issue
Block a user