Seite 1 von 1

QHttp über HTTPS ergibt ein "HTTP request failed"

Verfasst: 18. Juni 2009 12:27
von ms47
Hallo,

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;
}
Führe ich den Request per Http aus, also statt

Code: Alles auswählen

http.setHost(url.host(), QHttp::ConnectionModeHttps, url.port(443) );
dies:

Code: Alles auswählen

http.setHost(url.host(), QHttp::ConnectionModeHttp );
dann bekomme ich keinen Fehler und es funktioniert. Allerdings geht die Verbindung dann auch nicht über https.

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