2

I'd like to intercept POST requests made by JavaScript, read the POST data, and send a reply. Formerly with QWebKit, I used QNetworkAccessManager to do this.

With Qt 5.6, I had been hoping to use QWebEngineUrlRequestInterceptor to do the same.

However, I don't see any way to read the POST data. It gives me other information about there request just fine (such as the URL). Any idea how I can get the POST data?

Vern Jensen
  • 3,449
  • 6
  • 42
  • 59
  • 1
    Still curious if there is a way to read POST data, but if not, I can accomplish the same thing (with a little more work) by using this: http://doc.qt.io/qt-5/qwebchannel.html#details – Vern Jensen Feb 17 '16 at 21:05
  • Have you solved your problem ? I cannot even make QWebEngineUrlRequestInterceptor work in my program ,please help if you can http://stackoverflow.com/questions/38071731/print-out-all-the-requested-urls-during-loading-a-web-page – iMath Jun 29 '16 at 02:30
  • Yes -- I ended up using QWebChannel instead, which allows direct communication between Qt and JavaScript. It's very easy to use, and very fast. You can send data, and it'll convert strings, objects, arrays, whatever you want. – Vern Jensen Jun 30 '16 at 20:44
  • would it be possible to intercept a certain request during loading a web page using QWebChannel ? – iMath Jul 02 '16 at 01:42
  • 1
    Not that I know of. However, you CAN intercept web requests using another interface that I'm forgetting at the moment -- but I believe it's QNetworkAccessManager. The problem for me was that you could NOT read any POST data from the requests, and you could not intercept them in order to 'respond' to them. You could only see what the URL was. (All of this if I recall correctly.) Hence why I switched to QWebChannel. – Vern Jensen Jul 08 '16 at 00:26

0 Answers0