ich versuche mittels QHttp eine Verbindung zu einer Seite über https herzustellen. Leider bekomme ich den Fehler "HTTP request failed".
Das ist mal das Testprogramm.
Code: Alles auswählen
#include <QtCore/QCoreApplication>
#include <QBuffer>
#include <QHttp>
#include <QUrl>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QEventLoop loop;
QBuffer buffer;
QHttp http;
QObject::connect(&http, SIGNAL(done(bool)), &loop, SLOT(quit()));
QUrl url("https://gate1.goyyamobile.com/sms/sendsms.asp");
url.addQueryItem("receiver", "testnummer");
url.addQueryItem("sender", "tester");
url.addQueryItem("msg", "hallo");
url.addQueryItem("id", "id");
url.addQueryItem("pw", "pw");
url.addQueryItem("time", "0");
url.addQueryItem("msgtype", "0");
url.addQueryItem("test", "1");
if( url.isValid()==false )
{
qDebug() << "Die eingebene Url ist falsch";
return -1;
}
QString queryAndPath = url.encodedPath() + "?" + url.encodedQuery();
qDebug() << url.host();
qDebug() << queryAndPath;
// http.setHost(url.host(), QHttp::ConnectionModeHttp ); // <---- das funktioniert
http.setHost(url.host(), QHttp::ConnectionModeHttps, url.port(443) ); // <---- das funktioniert leider nicht
http.get(queryAndPath, &buffer);
loop.exec();
qDebug() << "Fehler: " << http.errorString();
QByteArray bytes;
bytes = buffer.buffer();
QString result(bytes);
qDebug() << result;
return 0;
}
Code: Alles auswählen
http.setHost(url.host(), QHttp::ConnectionModeHttps, url.port(443) );Code: Alles auswählen
http.setHost(url.host(), QHttp::ConnectionModeHttp );Hat vielleicht jemand einen Tipp für mich? Danke schon mal.
Gruß
Markus
Noch zur Ergänzung:
Gebe ich diese Url im Firefox ein, dann geht es auch
https://gate1.goyyamobile.com/sms/sends ... e=0&test=1
Hat also nichts mir dem Server zu tun