Add suggested_fn argument to get_request

This commit is contained in:
Iordanis Grigoriou 2017-06-26 23:21:32 +02:00
parent a24d7f6686
commit 8a5b48d374
2 changed files with 12 additions and 7 deletions

View File

@ -1443,9 +1443,13 @@ class CommandDispatcher:
download_manager.get_mhtml(tab, target)
else:
qnam = tab.networkaccessmanager()
download_manager.get(self._current_url(), user_agent=user_agent,
qnam=qnam, target=target,
title=self._current_title())
download_manager.get(
self._current_url(),
user_agent=user_agent,
qnam=qnam,
target=target,
suggested_fn=utils.sanitize_filename(tab.title() + ".html")
)
@cmdutils.register(instance='command-dispatcher', scope='window')
def view_source(self):

View File

@ -412,7 +412,7 @@ class DownloadManager(downloads.AbstractDownloadManager):
mhtml.start_download_checked, tab=tab))
message.global_bridge.ask(question, blocking=False)
def get_request(self, request, *, target=None, title=None, **kwargs):
def get_request(self, request, *, target=None, suggested_fn=None, **kwargs):
"""Start a download with a QNetworkRequest.
Args:
@ -428,9 +428,10 @@ class DownloadManager(downloads.AbstractDownloadManager):
request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
QNetworkRequest.AlwaysNetwork)
if request.url().scheme().lower() != 'data':
suggested_fn = (utils.sanitize_filename(title) + ".html" if title
else urlutils.filename_from_url(request.url()))
if suggested_fn is not None:
pass
elif request.url().scheme().lower() != 'data':
suggested_fn = urlutils.filename_from_url(request.url())
else:
# We might be downloading a binary blob embedded on a page or even
# generated dynamically via javascript. We try to figure out a more