small update
This commit is contained in:
@@ -86,7 +86,7 @@ class BasicResponseHandler(ResponseHandler):
|
||||
if 300 <= self.msg.status < 400:
|
||||
# Redirect
|
||||
self._skip_body()
|
||||
return self._do_handle_redirect()
|
||||
return self._handle_redirect()
|
||||
if 400 <= self.msg.status < 600:
|
||||
self._skip_body()
|
||||
# Dump headers and exit with error
|
||||
@@ -96,7 +96,7 @@ class BasicResponseHandler(ResponseHandler):
|
||||
|
||||
return None
|
||||
|
||||
def _do_handle_redirect(self):
|
||||
def _handle_redirect(self):
|
||||
if self.msg.status == 304:
|
||||
print("".join(self.msg.raw), end="")
|
||||
return None
|
||||
@@ -157,7 +157,8 @@ class DownloadHandler(ResponseHandler, ABC):
|
||||
return tmp_path
|
||||
|
||||
def get_filename(self):
|
||||
"""Returns the filename to download the payload to.
|
||||
"""
|
||||
Returns the filename to download the payload to.
|
||||
"""
|
||||
filename = os.path.basename(self.cmd.path)
|
||||
if filename == '':
|
||||
@@ -211,6 +212,13 @@ class HTMLDownloadHandler(DownloadHandler):
|
||||
return self.path
|
||||
|
||||
def _download_images(self, tmp_filename, target_filename, charset=FORMAT):
|
||||
"""
|
||||
Downloads images referenced in the html of `tmp_filename` and replaces the references in the html
|
||||
and writes it to `target_filename`.
|
||||
@param tmp_filename: the path to the temporary html file
|
||||
@param target_filename: the path for the final html fil
|
||||
@param charset: the charset to decode `tmp_filename`
|
||||
"""
|
||||
|
||||
try:
|
||||
fp = open(tmp_filename, "r", encoding=charset)
|
||||
|
Reference in New Issue
Block a user