ciao!
ho un problema con QNetworkRequest.
questo il codice:
codice:
Service::Service()
{
qDebug() << "started" << endl;
QNetworkRequest request(QUrl("........."));
qDebug() << "requested" << endl;
QNetworkAccessManager manager;
QNetworkReply* reply = manager.get(request);
qDebug() << "get" << endl;
if (reply->error())
{
qDebug() << "ERROR!";
qDebug() << reply->errorString();
}
else
{
qDebug() << "content" << endl;
qDebug() << reply->header(QNetworkRequest::ContentTypeHeader).toString();
qDebug() << "last" << endl;
qDebug() << reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().toString();
qDebug() << "length" << endl;
qDebug() << reply->header(QNetworkRequest::ContentLengthHeader).toULongLong();
qDebug() << "status" << endl;
qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
}
qDebug() << "finished" << endl;
}
la risposta è questa:
codice:
started
requested
get
content
""
last
""
length
0
status
0
finished
in sostanza mi escono solo i valori messi a mano, ma non ho risultati.
il servizio mi dovrebbe restituire una stringa json (che parserei in seguito).
l'url è corretto perchè testato sul browser, e cmq non cado nell'if dell'errore.
dove sto sbagliando??