Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Can't setup proxy credentials
Forum Updated to NodeBB v4.3 + New Features

Can't setup proxy credentials

Scheduled Pinned Locked Moved Unsolved QtWebEngine
6 Posts 2 Posters 818 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zabarne
    wrote on last edited by Zabarne
    #1

    Hi guys

    I'm struggling to figure out why my QT6.5.3 application (macOS) can't set the proxy username and password.

    The HTTP request arrives to my proxy as expected, but the username/password are not set.

    #include <QUrl>
    #include <QDebug>
    #include <QSettings>
    #include <QApplication>
    #include <QNetworkProxy>
    #include <QNetworkAccessManager>
    #include <QWebEnginePage>
    #include <QWebEngineView>
    #include <QCoreApplication>
    #include <QWebEngineSettings>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QNetworkProxy proxy;
        proxy.setType(QNetworkProxy::HttpProxy);
        proxy.setHostName(QString("127.0.0.1"));
        proxy.setPort(8084);
        proxy.setUser(QString("user"));
        proxy.setPassword(QString("password123"));
        QNetworkProxy::setApplicationProxy(proxy);
    
        QUrl url = QUrl(QStringLiteral("https://www.google.com/"));
    
        QWebEngineView view;
        QWebEnginePage page;
        view.setPage(&page);
        view.setUrl(url);
        view.show();
    
        return app.exec();
    }
    

    This is what my proxy gets:

    CONNECT www.google.com:443 HTTP/1.1\r\n
    Host: www.google.com:443\r\n
    Proxy-Connection: keep-alive\r\n
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/6.5.3 Chrome/108.0.5359.220 Safari/537.36\r\n\r\n
    

    Unfortunately, no Proxy-Authorization HTTP header was sent.

    If i try the same test using cuRL, everything works as expected:

    $ curl --proxy "http://127.0.0.1:8084" --proxy-user "user:password123" "https://www.google.com"
    

    My proxy gets the following:

    CONNECT www.google.com:443 HTTP/1.1\r\n
    Host: www.google.com:443\r\n
    Proxy-Authorization: Basic YXJjaGlkOmZvbw==\r\n
    User-Agent: curl/8.3.0\r\n
    Proxy-Connection: Keep-Alive\r\n\r\n
    

    The Proxy-Authorization HTTP header was sent as expected.

    What am i missing here?
    Help appreciated.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Aren't you missing a call to QtWebEngine::initialize(); ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Z 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Aren't you missing a call to QtWebEngine::initialize(); ?

        Z Offline
        Z Offline
        Zabarne
        wrote on last edited by Zabarne
        #3

        @SGaist said in Can't setup proxy credentials:

        QtWebEngine::initialize();

        I'm unable to find the QT header file to include for "QtWebEngine"
        This didn't work:

        #include <QtWebEngine>
        

        Hmmm ... this function QtWebEngine::initialize();doesn't seem to even exist under QT6.x (I'm using QT6.5.3).

        Help please.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Looks like things have changed a bit in Qt 6.
          You check the bug report system as from your code, you seem to have done everything correctly.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Z 1 Reply Last reply
          0
          • SGaistS SGaist

            Looks like things have changed a bit in Qt 6.
            You check the bug report system as from your code, you seem to have done everything correctly.

            Z Offline
            Z Offline
            Zabarne
            wrote on last edited by
            #5

            @SGaist I created a ticket the same day. But no one was assigned to it
            https://bugreports.qt.io/browse/QTBUG-117710

            SGaistS 1 Reply Last reply
            0
            • Z Zabarne

              @SGaist I created a ticket the same day. But no one was assigned to it
              https://bugreports.qt.io/browse/QTBUG-117710

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Thanks for the ticket. Your conclusion is wrong though, the WebEngine team is assigned.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved