Unsolved QWebEngineUrlRequestInterceptor - get headers
-
I'm handling requests by installing
QWebEngineUrlRequestInterceptor
. That works fine butQWebEngineUrlRequestInfo
doesn't haveheaders()
property. I'm only able add new header byQWebEngineUrlRequestInfo::setHttpHeader
. I have googled for solution and found that I can also installQWebEngineUrlSchemeHandler
but seems that it is not working or it isn't what I expected. I'm initializing as suggested in doc:int main(int argc, char *argv[]) { QWebEngineUrlScheme scheme("myscheme"); scheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort); scheme.setDefaultPort(2345); scheme.setFlags(QWebEngineUrlScheme::SecureScheme); QWebEngineUrlScheme::registerScheme(scheme); QApplication a(argc, argv); // installUrlSchemeHandler does not take ownership of the handler. MySchemeHandler *handler = new MySchemeHandler(&a); QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("myscheme", handler); .... }
Header:
class MySchemeHandler : public QWebEngineUrlSchemeHandler { Q_OBJECT public: MySchemeHandler(QObject *parent = nullptr); void requestStarted(QWebEngineUrlRequestJob *request) override; };
cpp:
MySchemeHandler::MySchemeHandler(QObject *parent) : QWebEngineUrlSchemeHandler(parent) { } void MySchemeHandler::requestStarted(QWebEngineUrlRequestJob *request) { qDebug() << "test"; }
But
requestStarted
is never triggered -
Well, now I know,
QWebEngineUrlSchemeHandler
is for custom scheme only, so for example formyscheme://
. If I try to overridehttp://
orhttps://
then my app is crashing. So, is there any way to intercepthttp://
/https://
headers? Is it intentionally limited due to security issues or is it not possible because it is encrypted on SSL layer? -
@Kobid
Similarly Apple doesn't allow http or https with WKURLSchemeHandler : "A protocol for loading resources with URL schemes that WebKit doesn't know how to handle". https://developer.apple.com/documentation/webkit/wkurlschemehandlerSadly no freedom to override internal handlers for "standard" protocols in QWebEngine, no way to manipulate the response, not even to inspect it !
With CEF you can.