4

I'm working on a simple web browser project that uses QtWebEngine.

What I want to is to log out the httpRequest and httpResponse data that transit in my browser. I only interest in http POST transitions.

In chrome's developer's tool, I can do this by go to Network tab, turn on Preserve log. What I need is

Headers>General>Request URL
       >From Data (params of POST)
Response (the raw response data)

Since QtWebEngine uses Chromium, I suppose that most things that chrome can do can also be done in QtWebEngine.

How can I get the above three things using QtWebEngine?

If there is no obvious way to do that, can I write an extension to log them out and make QtWebEngine use this extension? I think in extension I can log out http request header but I have no idea of how to log out the response data.

Edit: I don't want to an external debug tool (like port the log to localhost:myport). I need to use those three pieces of data in my browser application.

Edit2:

chrome.devtools.network.onRequestFinished.addListener

Yes somehow I need this but how can I call this or receive a similar event with Qt5.7?

user3819226
  • 461
  • 1
  • 5
  • 17
  • 2
    For request part you could use [QWebEngineUrlRequestInterceptor](https://doc-snapshots.qt.io/qt5-5.6/qwebengineurlrequestinterceptor.html#details), see [this answer](http://stackoverflow.com/a/40313601/1217285) of mine for more details. – Dmitry Oct 29 '16 at 15:52
  • Did you ever get a solution to this in the end? I also need to get the request and response data (possibly by intercepting a `QWebEngineHttpRequest` but I'm not sure how). Rather than using a `QWebEngineUrlRequestInterceptor` to get the urls however, I need to get the actual data. – SamG101 May 11 '20 at 07:30
  • Any update on this this someone succeeded to do ti? – Vesko Vujovic Oct 27 '22 at 08:10

0 Answers0