Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92932

[REG 5.12 -> 5.13] QWebEngineUrlRequestInterceptor doesn't get called for websocket connections

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.4.0 Beta1, 6.5.0 Beta1
    • 5.13.2, 5.15.3
    • WebEngine
    • None
    • 7b3570a962 (qt/qtwebengine/dev) b04bab528b (qt/qtwebengine/6.4) b04bab528b (qt/tqtc-qtwebengine/6.4)

    Description

      Starting with QtWebEngine 5.13, an installed QWebEngineUrlRequestInterceptor will not be called for WebSocket connections anymore.

      This can be reproduced by patching simplebrowser like so:

      diff --git i/examples/webenginewidgets/simplebrowser/main.cpp w/examples/webenginewidgets/simplebrowser/main.cpp
      index ddc8b4d0..c7c42616 100644
      --- i/examples/webenginewidgets/simplebrowser/main.cpp
      +++ w/examples/webenginewidgets/simplebrowser/main.cpp
      @@ -54,6 +54,8 @@
       #include <QApplication>
       #include <QWebEngineProfile>
       #include <QWebEngineSettings>
      +#include <QWebEngineUrlRequestInterceptor>
      +#include <QDebug>
       
       QUrl commandLineUrlArgument()
       {
      @@ -65,6 +67,16 @@ QUrl commandLineUrlArgument()
           return QUrl(QStringLiteral("https://www.qt.io"));
       }
       
      +class Interceptor : public QWebEngineUrlRequestInterceptor
      +{
      +    void interceptRequest(QWebEngineUrlRequestInfo&);
      +};
      +
      +void Interceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
      +{
      +    qDebug() << info.requestUrl();
      +}
      +
       int main(int argc, char **argv)
       {
           QCoreApplication::setOrganizationName("QtExamples");
      @@ -79,6 +91,9 @@ int main(int argc, char **argv)
           QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
           QWebEngineProfile::defaultProfile()->setUseForGlobalCertificateVerification();
       #endif
      +    Interceptor interceptor{};
      +    //QWebEngineProfile::defaultProfile()->setRequestInterceptor(&interceptor);
      +    QWebEngineProfile::defaultProfile()->setUrlRequestInterceptor(&interceptor);
       
           QUrl url = commandLineUrlArgument();
       

      And then visiting https://libwebsockets.org/testserver/ - or alternatively, visit http://www.websocket.org/echo.html and click "Connect", though that website seems semi-down at the moment.

      With Qt 5.12, QUrl("wss://libwebsockets.org/") is logged and setting custom headers on it works fine. With Qt 5.13+, even when using the deprecated setRequestInterceptor, the connection isn't intercepted at all.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt_webengine_team Qt WebEngine Team
              the compiler Florian Bruhin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes