Qt Https request with openssl - No response
-
Hey guys,
I'm trying to get my problem solved the last days, but I can't. I've read many forums but unfortunately I've found no solution, maybe someone can help me.My intention is to communicate with an webservice. The code should work, but when I'm executing it, I don't get any answer. I should receive some information about my request, but there is no response. Did I miss something? I've also included some openssl libraries. In the .pro file as well as on the system. At the moment I'm running windows 10 with Qt 5.11 on it.
I've read about some issues according to the incompatibility between Qt 5.11 and openssl 1.1.0, so I've already installed 1.0.2. But nothing...Here is my code for the request:
Testing::Testing(QObject *parent) : QObject (parent) { connect(&manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); // no proxy QNetworkProxyFactory::setUseSystemConfiguration(true); manager.setProxy(QNetworkProxy(QNetworkProxy::NoProxy)); QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy)); } void Testing::doRequest() { // request QString requestURL = QString("https://account.radiobridge.io/account/"); QUrl url(requestURL); QNetworkRequest request; request.setUrl(url); request.setRawHeader(QByteArray("accept"),QByteArray("application/json")); QNetworkReply* currentReply = manager.get(request); // GET } void Testing::replyFinished(QNetworkReply *reply) { if (reply->error()) { qWarning() << "ErrorNo: " << reply->error() << "for url: " << reply->url().toString(); qDebug() << "Request failed, " << reply->errorString(); }else { qDebug() << "Content: " << reply->readAll(); } } int main(int argc, char *argv[]) { Testing t; t.doRequest(); }
Here is my .pro file:
QT += core QT += network QT -= gui HEADERS += \ accountmanager.h \ radiostationlist.h \ radiostation.h \ testing.h SOURCES += \ demo.cpp \ accountmanager.cpp \ radiostationlist.cpp \ radiostation.cpp \ testing.cpp LIBS += E:/Programme/OpenSSL-Win64/lib/libeay32.lib LIBS += E:/Programme/OpenSSL-Win64/lib/ssleay32.lib
That's the console output:
C:\Users\thanh\Desktop\build-Alpini-Desktop_Qt_5_11_2_MinGW_32bit-Debug\debug\Alpini... C:/Users/thanh/Desktop/build-Alpini-Desktop_Qt_5_11_2_MinGW_32bit-Debug/debug/Alpini wurde mit dem Rückgabewert 0 beendet
Hopefully, there is somebody who can help me.
Best regards,
Thanni -
Can create the QApplication object & Start the event loop like follows ?
int main(int argc, char *argv[])
{
QApplication a(argc,argv)
Testing t;
t.doRequest();
a.exec()
}