Can't setup proxy credentials
-
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. -
Hi,
Aren't you missing a call to
QtWebEngine::initialize();
? -
@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.
-
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.