Fix some issues, improve documentation
This commit is contained in:
@@ -46,20 +46,6 @@ class ResponseHandler(ABC):
|
||||
def handle(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def parse_uri(uri: str):
|
||||
parsed = urlsplit(uri)
|
||||
|
||||
# If there is no netloc, the url is invalid, so prepend `//` and try again
|
||||
if parsed.netloc == "":
|
||||
parsed = urlsplit("//" + uri)
|
||||
|
||||
host = parsed.netloc
|
||||
path = parsed.path
|
||||
if len(path) == 0 or path[0] != '/':
|
||||
path = "/" + path
|
||||
return host, path
|
||||
|
||||
|
||||
class BasicResponseHandler(ResponseHandler):
|
||||
"""
|
||||
@@ -98,11 +84,14 @@ class BasicResponseHandler(ResponseHandler):
|
||||
if 300 <= self.msg.status < 400:
|
||||
# Redirect
|
||||
return self._do_handle_redirect()
|
||||
if 400 <= self.msg.status < 500:
|
||||
if 400 <= self.msg.status < 600:
|
||||
# Dump headers and exit with error
|
||||
print("".join(self.msg.raw), end="")
|
||||
if not self.cmd.sub_request:
|
||||
print("".join(self.msg.raw), end="")
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
def _do_handle_redirect(self):
|
||||
self._skip_body()
|
||||
|
||||
|
Reference in New Issue
Block a user