Share cookies with KIO and improve downloads

Authored by stefanocrocco on Nov 12 2017, 9:20 AM.



Downloads from sites requiring authentication often failed because KIO (used for downloads) didn't have access to the cookies sent to QWebEngine. To fix this, now the cookies are added to the KIO store in response to the QWebEngineCookieStore::cookieAdded signal.

Unfortunately, KIO requires to know a cookie's origin URL, which QWebEngineCookieStore doesn't provide. As a workaround, WebEnginePartDownloadManager now also keeps trace of the last page being loaded and uses its URL as origin URL for cookies. This is not ideal and is likely to fail if more than one page is loaded at the same time. For the time being, however, I don't see a better way to do this.

Also, improve downloads in the following ways:

  • if WebEnginePartDownloadManager can't find out which part asked for a given download, download the file using QWebEngineDownloadItem::accept rather than doing nothing
  • if QWebEngineDownloadItem::type is SavePage, do it using QWebEngineDownloadItem::accept (only supported for Qt 5.8 or greater)
  • if QWebEngineDownloadItem::type is Attachment or DownloadAttribute, ask the user whether to open or save it rather (only supported for Qt 5.8 or greater)
Test Plan

Before these changes, downloading files from sites requiring authentication (for example, my bank's site) failed because instead of downloading the requested file, Konqueror downloaded an HTML page (which often was a login page). After these changes, the files are downloaded correctly.

Diff Detail

R226 Konqueror
Lint Skipped
Unit Tests Skipped
stefanocrocco created this revision.Nov 12 2017, 9:20 AM
stefanocrocco abandoned this revision.Jul 12 2019, 7:40 AM

Oops I forgot to review this one?