small fixes
This commit is contained in:
@@ -62,9 +62,10 @@ class ResponseHandler(ABC):
|
||||
|
||||
|
||||
class BasicResponseHandler(ResponseHandler):
|
||||
""" Response handler which throws away the body and only shows the headers.
|
||||
"""
|
||||
Response handler which throws away the body and only shows the headers.
|
||||
In case of a redirect, it will process it and pass it to the appropriate response handler.
|
||||
"""
|
||||
"""
|
||||
|
||||
def __init__(self, client: HTTPClient, msg: Message, cmd: AbstractCommand):
|
||||
retriever = Retriever.create(client, msg.headers)
|
||||
@@ -105,10 +106,15 @@ class BasicResponseHandler(ResponseHandler):
|
||||
def _do_handle_redirect(self):
|
||||
self._skip_body()
|
||||
|
||||
if self.msg.status == 304:
|
||||
print("".join(self.msg.raw), end="")
|
||||
return None
|
||||
|
||||
location = self.msg.headers.get("location")
|
||||
if not location:
|
||||
if not location or len(location.strip()) == 0:
|
||||
raise InvalidResponse("No location in redirect")
|
||||
|
||||
location = parser.urljoin(self.cmd.uri, location)
|
||||
parsed_location = urlsplit(location)
|
||||
if not parsed_location.hostname:
|
||||
raise InvalidResponse("Invalid location")
|
||||
|
Reference in New Issue
Block a user