QtWebEngine/Network

From Qt Wiki
< QtWebEngine
Revision as of 08:26, 17 November 2016 by Kkoehne (talk | contribs)
Jump to navigation Jump to search


Qt WebEngine uses the Chromium networking stack instead of Qt Network. This also means that the setup of proxies might differ. In general, Qt WebEngine should follow the 'least surprising route' and follow the proxy settings of Qt Network.

Proxy Resolution

Note: If the first page takes long too load, this is often because Qt WebEngine queries the network for a PAC (Proxy Auto-Configuration) file.

Proxy resolution in Qt Network

Qt Network has a various levels to set proxies for client connections (evaluated in this order):

  1. QAbstractSocket::setProxy
  2. QNetworkAccessManager::setProxy
  3. QNetworkAccessManager::setProxyFactory
  4. QNetworkProxy::setApplicationProxy
  5. QNetworkProxyFactory::setUseSystemConfiguration
  6. QNetworkProxyFactory::setApplicationProxyFactory

Since Qt 5.6, there's a default QNetworkProxyFactory::applicationProxyFactory that uses the system settings (see -system-proxies / -no-system-proxies configure flag).

Proxy resolution in Qt WebEngine

Qt WebEngine checks QNetworkProxy::applicationProxy once. If there is a proxy set, it is used for Chromium connections too (see proxy_config_service_qt.cpp). Then QNetworkProxyFactory::applicationProxyFactory is checked (since Qt 5.8). If it is enabled, Chromium tries to auto-detect the system proxy settings. Before Qt 5.8, this was always the case.

Note: The code path used to auto-detect proxy settings in the network differ, depending on whether --single-process is used. See https://codereview.qt-project.org/#/c/115567/ for details.

Proxy authentication

To authenticate proxies, connect to the QWebEnginePage::proxyAuthenticationRequired or WebEngineView::authenticationDialogRequested signal.

Links

http://doc.qt.io/qt-5/qtwebengine-overview.html#proxy-support