Home > Back-end >  Qt network programming can't get the data
Qt network programming can't get the data

Time:12-23

Token is post, according to the url and token to get the data, and token url here is no problem, return the result is 200, but after the get the systeminfo is empty!
Excuse me, is what went wrong,,

To find a solution was added in this request. The setAttribute (QNetworkRequest: : FollowRedirectsAttribute, true); You can redirect
But it was useless,,,


 void AddId: : getCriticalMsg (QString url, QString token) 
{
QDebug () & lt; <"1";
//build request object
QNetworkRequest request;

//send HTTPS request preparation work before;
QSslConfiguration config.
QSslConfiguration conf=request. SslConfiguration ();
The conf. SetPeerVerifyMode (QSslSocket: : VerifyNone);
The conf. SetProtocol (QSsl: : TlsV1SslV3);
Request. SetSslConfiguration (conf);
//request. SetUrl (QUrl (" https://www.baidu.com "));
Request. SetUrl (QUrl (url));
QDebug () & lt; <"2";
//set the url and xAuthToken

//set the request header
//request. SetHeader (QNetworkRequest: : ContentTypeHeader, "application/json");
Request. SetRawHeader (QByteArray (" X-ray Auth - Token "), QByteArray (Token) toUtf8 ()));

QDebug () & lt; <"3";
//send the request

Systeminfo QNetworkReply *=manager - & gt; Get (request);
Request. SetAttribute (QNetworkRequest: : FollowRedirectsAttribute, true);
QDebug () & lt; <"4".

QDebug () & lt;
  • Related