Reputation: 21
I want to capture server http response in qt demo browser and check the header fields. How to implement this using qt webengine? I also saw QWebEngineUrlRequestInterceptor but using this class we cant read http header fields.
Upvotes: 1
Views: 987
Reputation: 1152
I think is not possible. You can use a QWebEngineUrlRequestInterceptor to intercep your requests. Here I'm adding a bearer token for all requests, but I think is impossible to read headers
void customInterceptor ::interceptRequest(QWebEngineUrlRequestInfo &info)
{
info.setHttpHeader("Authorization", ("Bearer " + m_token).toLocal8Bit());
info.setHttpHeader("accept-language", Translator::instance()->getCurrentLang().toLocal8Bit());
}
Upvotes: 0
Reputation: 131
you need to run your browser with remote debug to enable chrome dev tools: set 'QTWEBENGINE_REMOTE_DEBUGGING' = port , in QT environment . after that from other qtwebengine instance connect to localhost:port , then you can use all chromium dev tools ,monitor/manipulate all network traffic .
If you do not need visualization , then need to make your own client for chromium dev tools protocol(they have pretty good manuals) . Collect all responses in way you prefer , in responses look for method='Network.responseReceived' , with available selector (for example response['params']['response']['url'] ) , then you will have in you response response['params']['requestId'] , with requestId you can do Network.getResponseBody(requestId=response['params']['requestId']) .
Upvotes: 0