On lunedì 30 ottobre 2017 21:23:04 CET Albert Astals Cid wrote:
> El diumenge, 29 d’octubre de 2017, a les 9:47:24 CET, Stefano Crocco va
> 
> escriure:
> > Hello to everyone,
> > I'm working on making QWebEngine work correctly in Konqueror when
> > downloading files (although I didn't have much time to spend on this in
> > the
> > last months).
> > 
> > The problem is that instead of downloading the correct files, in some
> > cases
> > Konqueror download html files. This only happens from sites requiring
> > authentication (I first noticed when trying to download a file from my
> > bank's web page); besides, it only happens if I try to use KIO for the
> > download, for example calling KIO::copy from a slot connected with
> > QWebEngineProfile::downloadRequested. The file downloads correctly if
> > Konqueror downloads it using the mechanism provided by QWebEngine, that is
> > calling QWebEngineDownloaditem::accept.
> > 
> > I believe that the issue is caused by cookies, and in particular by the
> > fact that QWebEngine doesn't share its cookies with KIO so that, when KIO
> > attempts to download the file, it doesn't have the cookie(s) associated
> > with the session opened in the browser and the web page refuses to let it
> > download the file (indeed, one of the sites where this happens returned a
> > login page instead of the PDF I wanted to download).
> > 
> > Looking at the documentation both for QWebEngine and for KIO
> > regarding cookies. I found out two classes:
> > * on QWebEngine's side, there's QWebEngineCookieStore, which provides
> > signals emitted whenever a cookie is added or removed and which, according
> > to documentation [1], "can be used to synchronize cookies of Chromium and
> > the QNetworkAccessManager"
> > * on KIO's side, there's KIO::Integration::AccessManager, which derives
> > from QNetworkAccessManager and which should work along
> > QWebEngineCookieStore.
> > 
> > The example in the documentation for KIO::Integration::AccessManager
> > refers
> > to QWebView and says to call QWebPage::setNetworkAccessManager to have the
> > QWebView and KIO to use the same access manager. Unfortunately, QWebEngine
> > can't be integrated with a QNetworkAccessManager: not only QWebEnginePage
> > doesn't have a setNetworkAccessManager method, but the documentation for
> > QWebEngine explicitly says that it doesn't use QNetworkAccess. Because of
> > this, I thought to do things the other way round: I created a
> > KIO::Integration::AccessManager and, used slots connected with
> > QWebEngineCookieStore signals, to add cookies to it.
> > 
> > Unfortunately, this doesn't fix the issue. I believe this is because I
> > haven't told KIO to use the new access manager. The problem is that I can
> > see any way to do it. Does anyone have suggestions on how to do this?
> 
> Since your question is related to KIO you may want to ask in
> kde-frameworks-de...@kde.org if noone answers here.
> 
> Cheers,
>   Albert
> 
> > Thanks
> > 
> > Stefano
> > 
> > [1] http://doc.qt.io/qt-5/qwebenginecookiestore.html#details

Thanks for the advice. I'll wait a couple more days and if I'll receive no 
answers here I'll try there.

Stefano

Reply via email to