[Interest] QWebEngine: Http POST request with payload data

Jason Dolan jason at pcc.com
Fri Mar 10 18:51:46 CET 2017


Hey Allen,

Do you have an example of how to issue the HTTP POST request with QNetworkAccessManager and then hand off the response to QWebEngineView (including setting up the cookies)?  I’m having trouble getting this to work.

> On Mar 8, 2017, at 3:41 AM, Allan Sandfeld Jensen <kde at carewolf.com> wrote:
> 
> On Tuesday 07 March 2017, Jason Dolan wrote:
>>> On Mar 6, 2017, at 12:10 PM, Allan Sandfeld Jensen <kde at carewolf.com>
>>> wrote:
>>> 
>>> On Monday 06 March 2017, Jason Dolan wrote:
>>>> Ahh, of coarse there is a solution in the *next* release.  I feel like
>>>> that’s always the case with QWebEngine since Qt 5.0.  Well, I guess it
>>>> takes a while for it to become a full fledged replacement for QWebkit.
>>>> 
>>>> Guess I’ll go the Javascript route until we migrate to Qt 5.9.
>>> 
>>> Another option is to use QNetworkAccessManager, especially if you don't
>>> need the response body, though even if you do, you could try to inject
>>> it with QWebEnginePage::setData().
>>> 
>>> Best regards
>>> `Allan
>> 
>> Interesting thought… I do need the response however.  I’m using this as a
>> SSO into a website.  The SSO parameters are sent along in the URL and the
>> payload is additional data for when you have successfully logged in.  I
>> don’t think QWebEnginePage::setData() will work, because part of the SSO
>> is creating a session connection for further navigation around the site, 
>> “logging in” via QNetworkAccessManager, then passing the result to
>> QWebEnginePage will not carry along cookie session info AFAIK.
>> 
> You can do that too. The cookies for QNetworkAccessManager can be read from 
> QNetworkCookieJar and inserted into QWebEngineCookieStore. I think we
> had an example for that at one point.
> 
> Regards
> `Allan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170310/ded02900/attachment.html>


More information about the Interest mailing list