|
|
|
@ -1548,6 +1548,8 @@ class Download: public Command { |
|
|
|
|
} |
|
|
|
|
bool execute(Script* script, QWebFrame* frame) { |
|
|
|
|
Logger log(this, script); |
|
|
|
|
_realfilename = script->replacevars(_filename); |
|
|
|
|
log("REALFILENAME="+_realfilename); |
|
|
|
|
frame->page()->setForwardUnsupportedContent(true); |
|
|
|
|
connect(frame->page(), SIGNAL(unsupportedContent(QNetworkReply*)), |
|
|
|
|
this, SLOT(unsupportedContent(QNetworkReply*))); |
|
|
|
@ -1577,16 +1579,15 @@ class Download: public Command { |
|
|
|
|
_filesuccess = filesuccess; |
|
|
|
|
} |
|
|
|
|
void unsupportedContent(QNetworkReply* reply) { |
|
|
|
|
_realfilename = reply->url().toString().split('/').last(); |
|
|
|
|
if (_filename.size()) |
|
|
|
|
_realfilename = _filename; |
|
|
|
|
else if (reply->header(QNetworkRequest::ContentDispositionHeader) |
|
|
|
|
.isValid()) { |
|
|
|
|
QString part(reply->header(QNetworkRequest::ContentDispositionHeader) |
|
|
|
|
.toString()); |
|
|
|
|
if (part.contains(QRegularExpression("attachment; *filename="))) { |
|
|
|
|
part.replace(QRegularExpression(".*attachment; *filename="), ""); |
|
|
|
|
if (part.size()) _realfilename = part; |
|
|
|
|
if (!_realfilename.size()) { |
|
|
|
|
_realfilename = reply->url().toString().split('/').last(); |
|
|
|
|
if (reply->header(QNetworkRequest::ContentDispositionHeader).isValid()) { |
|
|
|
|
QString part(reply->header(QNetworkRequest::ContentDispositionHeader) |
|
|
|
|
.toString()); |
|
|
|
|
if (part.contains(QRegularExpression("attachment; *filename="))) { |
|
|
|
|
part.replace(QRegularExpression(".*attachment; *filename="), ""); |
|
|
|
|
if (part.size()) _realfilename = part; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
connect(new RunDownload(reply, _realfilename), |
|
|
|
|