0

For developing my browser application, I have installed a QWebEngineUrlRequestInterceptor, so I can filter the URLs being reuquested. I would like to now be able to have a similar thing but for the server response content ie a theoretical QWebEngineServerResponseInterceptor kind of class. I am unaware of any classes that exist, and I don't even know whether the QtWebEngine even supports intercepting server responses, as this may go directly to the Chromium Networking Stack, and therefore bypass the QtWebEngine completely. I'd like to be able to read and modify Javascipt, html, etc... before it is loaded into the QWebEngineView.

I was thinking of blocking all URLs in the QWebEngineUrlRequestInterceptor, and then requesting them individually with a QNetworkAccessManager, however I think this is a bad idea because Qt switched to the Chromium Networking Stack for a reason and also whilst I could analyse the response with the QNetworkReply, I don't know how to load this into the QWebEngineView, or how to capture and load the POST data into the POST requests.

Is there some sort of workaround that I could use, in order to read and modify the server response content before it is loaded into the QWebEngineView?

SamG101
  • 376
  • 3
  • 16
  • Why don't you implement an external proxy that does that job? – eyllanesc May 26 '20 at 22:55
  • I'd like to have all the intercepting done on the same device making the http requests, as the backend of the application will have a complex packet routing system, done via other devices. – SamG101 May 28 '20 at 07:22
  • okay, as I already pointed out in other posts: There is no such class, I recommend reading the Qt WebEngine docs (there are few classes) before asking. – eyllanesc May 28 '20 at 12:59
  • Okay thanks, do you know if it safe to use the QtNetwork instead of the Chromium Networking Stack - by blocking all urls in a `QWebEngineRequestUrlInterceptor` and then requesting them manually through a `QNetworkAccessManager`? – SamG101 May 28 '20 at 14:48
  • No, it is not possible. – eyllanesc May 28 '20 at 18:29
  • I have thought of a possible workaround solution; In the `interceptRequest` function of a `QWebEngineUrlRequestInterceptor`, manually request the urls and store the reply (`QNetworkReply.readAll()`), and then redirect the original url request to the locally saved version, also allows for offline browsing to these sites. – SamG101 May 28 '20 at 18:45

0 Answers0