QtWebEngine/Network: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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.
[[Category:Developing Qt]]
 
Qt WebEngine uses the Chromium networking stack instead 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 ===
=== Proxy resolution in Qt Network ===


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


# [http://doc.qt.io/qt-5/qabstractsocket.html#setProxy QAbstractSocket::setProxy]
# [http://doc.qt.io/qt-5/qabstractsocket.html#setProxy QAbstractSocket::setProxy]
# [http://doc.qt.io/qt-5/qnetworkaccessmanager.html#setProxy QNetworkAccessManager::setProxy]
# [http://doc.qt.io/qt-5/qnetworkaccessmanager.html#setProxyFactory QNetworkAccessManager::setProxyFactory]
# [http://doc.qt.io/qt-5/qnetworkproxy.html#setApplicationProxy QNetworkProxy::setApplicationProxy]
# [http://doc.qt.io/qt-5/qnetworkproxy.html#setApplicationProxy QNetworkProxy::setApplicationProxy]
# [http://doc.qt.io/qt-5/qnetworkproxyfactory.html#setUseSystemConfiguration QNetworkProxyFactory::setUseSystemConfiguration]
# [http://doc.qt.io/qt-5/qnetworkproxyfactory.html#setApplicationProxyFactory QNetworkProxyFactory::setApplicationProxyFactory]
# [http://doc.qt.io/qt-5/qnetworkproxyfactory.html#setApplicationProxyFactory QNetworkProxyFactory::setApplicationProxyFactory]


Line 14: Line 22:
=== Proxy resolution in Qt WebEngine ===
=== 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 [https://code.woboq.org/qt5/qtwebengine/src/core/proxy_config_service_qt.cpp.html#_ZN20ProxyConfigServiceQt20GetLatestProxyConfigEPN3net11ProxyConfigE proxy_config_service_qt.cpp]). If not, Chromium will try to use the system proxy settings.
Qt WebEngine does not feature an API for setting proxies directly. Anyhow, it can
 
# Use the system proxy settings
# Use any proxy set explicitly in Qt Network
 
From Qt 5.8 onwards, The ''system proxy settings'' are used if [http://doc.qt.io/qt-5/qnetworkproxyfactory.html#usesSystemConfiguration QNetworkProxyFactory::usesSystemConfiguration] returns true.  
 
Otherwise Qt WebEngine adapts [http://doc.qt.io/qt-5/qnetworkproxy.html#applicationProxy QNetworkProxy::applicationProxy] . It does only use the following properties though:
 
* [http://doc.qt.io/qt-5/qnetworkproxy.html#type QNetworkProxy::type()]
* [http://doc.qt.io/qt-5/qnetworkproxy.html#hostName QNetworkProxy::hostName()]
* [http://doc.qt.io/qt-5/qnetworkproxy.html#port QNetworkProxy::port()]
 
Other settings in QNetworkProxy (or Qt Network in general) are ignored.


''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.
''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.

Latest revision as of 10:56, 21 July 2017


Qt WebEngine uses the Chromium networking stack instead 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 does not feature an API for setting proxies directly. Anyhow, it can

  1. Use the system proxy settings
  2. Use any proxy set explicitly in Qt Network

From Qt 5.8 onwards, The system proxy settings are used if QNetworkProxyFactory::usesSystemConfiguration returns true.

Otherwise Qt WebEngine adapts QNetworkProxy::applicationProxy . It does only use the following properties though:

Other settings in QNetworkProxy (or Qt Network in general) are ignored.

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