Intercepting WebKit network requests

  • TLDR; is there a good example which shows making asynchronous requests in a custom NetworkAccessManager ::createRequest function and responding only once the data is loaded?

    I have a web application that I would like to provide an offline version of. To do this I took my SPA app and wrapped it in a QT application. To make the ajax calls work I had to provide a custom network access manager.

    This all works beautifully except for one ajax call I make that actually has to make a web request. The rest simply load or save files.

    In my custom NAM ::createRequest function I return an incomplete QNetworkReply that is open for read. The readData function calls processEvents and returns -1 until I asynchronously receive data from the web request. At that point I populate the QNetworkRequest, fire the readyRead/complete events and let it go.

    The problem I am having is this leads to a 404 in Webkit and the data is not received even though as best I can tell it has been read from the QIODevice interface to the request.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.