Cruz
24th November 2016, 11:08
Hi!
I want to write a program that issues get, put, and delete HTTP requests. I tried to use the QNetworkAccessManager to accomplish this, but somehow not even a simple example works for me. Here is my code:
QNetworkAccessManager nm;
QNetworkReply* nr = nm.get(QNetworkRequest(QUrl(QString("http://www.yahoo.com"))));
while (!nr->isFinished())
{
sleep(10);
qDebug() << nr->isFinished() << nr->error() << (nr->request()).url();
}
And the output is:
qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
First of all, what are the SSL socket warnings about? I did not want to use an SSL connection here.
I used wireshark to observe the network traffic, and can see that not a single packet leaves my interface when using this code. It is not working.
And yes, I do not want to use the QNetworkManager in an asynchronous mode, I would rather wait in a loop until it is finished.
Can anyone tell me what I'm doing wrong?
Thanks
Cruz
I want to write a program that issues get, put, and delete HTTP requests. I tried to use the QNetworkAccessManager to accomplish this, but somehow not even a simple example works for me. Here is my code:
QNetworkAccessManager nm;
QNetworkReply* nr = nm.get(QNetworkRequest(QUrl(QString("http://www.yahoo.com"))));
while (!nr->isFinished())
{
sleep(10);
qDebug() << nr->isFinished() << nr->error() << (nr->request()).url();
}
And the output is:
qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
false 0 QUrl( "http://www.yahoo.com" )
First of all, what are the SSL socket warnings about? I did not want to use an SSL connection here.
I used wireshark to observe the network traffic, and can see that not a single packet leaves my interface when using this code. It is not working.
And yes, I do not want to use the QNetworkManager in an asynchronous mode, I would rather wait in a loop until it is finished.
Can anyone tell me what I'm doing wrong?
Thanks
Cruz