QWebEngine get response headers
-
@Devoo
Assuming you are Qt 5.6+, I bleieve your are supposed to accomplish this via QWebEngineUrlRequestInterceptor Class. See https://stackoverflow.com/questions/40309105/capture-server-response-with-qwebengineview -
@JonB
"Implementing the QWebEngineUrlRequestInterceptor interface and installing the interceptor on the profile enables intercepting, blocking, and modifying URL requests before they reach the networking stack of Chromium."As I understand it, this class is used to modify the request before it is sent, not after.
How can I use this class to read response headers? -
@JonB
"Implementing the QWebEngineUrlRequestInterceptor interface and installing the interceptor on the profile enables intercepting, blocking, and modifying URL requests before they reach the networking stack of Chromium."As I understand it, this class is used to modify the request before it is sent, not after.
How can I use this class to read response headers?@Devoo
Yes, I see what you mean. That title Capture server response with QWebEngineView looks good, but I agree the answer seems to be only for request, not response. I don't see anything equivalent for the response, so I don't know... And I think you have asked the same in a comment at stackoverflow :) -
I do not properly know the answer. However, reading this question piqued my curiosity, so I started down the path of trying to find an answer...
I have to stop my inquiry for today, but here is where I got...
There is a class inside
namespace QtWebEngineCore
namedDevToolsFrontendQt
, and this class seems to do some processing/handling of things of typeHttpResponseHeaders
.So, Qt webengine (which is based on Chromium) does seem to include some kind of DevTools UI.
https://doc.qt.io/qt-5/qtwebengine-debugging.html#qt-webengine-developer-tools
https://github.com/qt/qtwebengine/blob/cd12379d43/src/core/devtools_frontend_qt.h#L72
https://stackoverflow.com/questions/28681141/qtwebengine-debugging
Technically, this "Dev Tools" presence arguably constitutes some kind of "yes" answer to "Is there any way to get response headers?"
.... but probably not in the way you mean. If you only need to see the headers for debugging, then this could be acceptable. But I suspect you wish to intercept the headers programmatically as a built-in feature of your final application. If Qt has not yet exposed any end-user API for doing that in your application, then grepping the "qt/qtwebengine" source code for "HttpResponseHeaders" might suggest a way to hack into qtwebengine and make a custom build of it that exposes what you need. No doubt this would be a significant engineering effort.