Cannot get QNetworkCookie from QNetworkReply
void onFinished(QNetworkRequest * reply)
{
....
QVariant v = reply->header(QNetworkRequest::SetCookieHeader);
QList<QVariant> list = v.toList();
QList<QNetworkCookie> c = qvariant_cast<QList<QNetworkCookie> >(list);
....
}
I have a http detect tool,it tells me that the response contains 4 pieces of cookie.
But after calling v.toList(),I get a list whose length is 0.
So,what's wrong with it?
Re: Cannot get QNetworkCookie from QNetworkReply
I just find a post about this.
This code should be this to work:
Code:
QVariant v
= reply
->header
(QNetworkRequest
::SetCookieHeader);
QList<QNetworkCookie> c = qvariant_cast<QList<QNetworkCookie> >(v);