Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > С/С++: Кроссплатформенное программирование, Qt/Gtk+/wxWidgets > [QT4] QHttp + ssl -> GET по https


Автор: neosapient 1.7.2008, 18:10
Помогите новичку отправить запрос по https.
Хочу загрузить данные, для начала в файл. На сайте надо проходить авторизацию.

Прочел доку и кучу макулатуры литературы. В результате совсем запутался, а в голове каша.  smile 

Вот понасобирал строчки кода, как бы его исправить
Код


    QFile file("sometext.htm");
    QHttp http;
    if (file.open(QIODevice::WriteOnly)) {
        http.setUser("login","password");
        http.setHost("www.someurl.com");
        http.get("/sometext.htm", &file);
        http.close();
        file.close();
    }




Автор: SABROG 2.7.2008, 12:41
Код

http.setHost("www.someurl.com", QHttp::ConnectionModeHttps);

Автор: neosapient 2.7.2008, 12:51
Всё в разброд пошло: стоит подключить заголовочный файл
Код

#include <QHttp>


И сразу при попытке скомпилировать выдаются ошибки
Код

c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2144: syntax error : 'int' should be preceded by ';'
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2501: 'QT_BEGIN_NAMESPACE' : missing storage-class or type specifiers
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2146: syntax error : missing ';' before identifier 'QtNetworkModule'
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2371: 'QtValidLicenseForNetworkModule' : redefinition; different basic types
        d:\qt\include\QtCore\../../src\corelib\global\qglobal.h(2042) : see declaration of 'QtValidLicenseForNetworkModule'
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2501: 'QtNetworkModule' : missing storage-class or type specifiers
main.cpp(11) : error C2144: syntax error : 'int' should be preceded by ';'
main.cpp(11) : error C2501: 'QT_END_NAMESPACE' : missing storage-class or type specifiers
 

P.S.
Для примера собирается проект, в котором Qhttp не используются вообще
Код

#include <QApplication>
#include <QPushButton>
#include <QHttp>  // <-- без этого заголовка всё компилиться успешно

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QPushButton *button = new QPushButton("Quit");
    QObject::connect(button, SIGNAL(clicked()),
                     &app, SLOT(quit()));
    qDebug("Hello");
    button->show();
    return app.exec();
}


P.P.S.
Пути прописаны
C:\Qt\4.4.0\include\QtNetwork

Автор: SABROG 2.7.2008, 13:02
Похоже на косяки с компилятором.

Версия Qt для Msvc или Mingw ? Чем собираеш ? Версия компилятора ?

Автор: neosapient 2.7.2008, 13:21
Цитата(SABROG @ 2.7.2008,  13:02)
Похоже на косяки с компилятором.

Версия Qt для Msvc или Mingw ? Чем собираеш ? Версия компилятора ?

На машине VC6 и VC7 (обычно использую VC7 )

Изначально ставил opensource Qt4.3 . Месяц назад скачал и поставил лицензионный пакет интегрированный под VC7  Qt4.4

Собираю компилятором VC7 через командную строку


P.S.

Что обидно, пример из opensource Qt4.3 \examples\network\http собирается
А пример из лицензии Qt4.4 \examples\network\http НЕ собираеться - обидно


--------------------

Так, а где объявлены переменные QT_BEGIN_NAMESPACE и QT_END_NAMESPACE  и почему они не видяться?

Автор: anatox91 2.7.2008, 13:25
а в  .pro-файле есть строчка
Код

QT += network

?

Автор: neosapient 2.7.2008, 13:34
Цитата(anatox91 @ 2.7.2008,  13:25)
а в  .pro-файле есть строчка
Код

QT += network

?

О, помогло избавится от этих ошибок
Код

c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2144: syntax error : 'int' should be preceded by ';'
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2501: 'QT_BEGIN_NAMESPACE' : missing storage-class or type specifiers
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2146: syntax error : missing ';' before identifier 'QtNetworkModule'
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2371: 'QtValidLicenseForNetworkModule' : redefinition; different basic types
        d:\qt\include\QtCore\../../src\corelib\global\qglobal.h(2042) : see declaration of 'QtValidLicenseForNetworkModule'
c:\Qt\4.4.0\include\QtNetwork\qhttp.h(34) : error C2501: 'QtNetworkModule' : missing storage-class or type specifiers
main.cpp(11) : error C2144: syntax error : 'int' should be preceded by ';'
main.cpp(11) : error C2501: 'QT_END_NAMESPACE' : missing storage-class or type specifiers


Пошел тыкаться дальше
Ждите постов

Автор: neosapient 2.7.2008, 18:05
Почти готов сдаться smile .

В архиве пример из QT4.3   %QT4Dir%\examples\network\http

Когда его запускаешь и указываешь цель скачивания - он подвисает при скачивании.

Кто-нибудь решил эту проблему ?


Автор: SABROG 2.7.2008, 18:43
Qt сам собирал ? С OpenSSL ?

Автор: neosapient 2.7.2008, 19:00
Да, QT сам собрал.


Цитата

С OpenSSL ? 

Я так понял, что OpenSSL уже встроен в комплект. Выставил только флаги.


Тема временно переезжает на http://forum.vingrad.ru/forum/topic-219086/anchor-entry1568000/0.html
Надеюсь сюда ещё вернемся  smile 

-------------
сутки спустя
Ну вот и вернулись.
Так я прав, что вариант OpenSSL уже входит в комплект QT ?
-------------
спустя полдня

OpenSSL надо ставить отдельно

Решил пересобрать согласно статьям

http://bombus.jrudevels.org/wiki/howto/psi_qt4
http://forum.sources.ru/index.php?showtopic=235803&view=showall

Автор: neosapient 3.7.2008, 17:43
Пересобрал QT4 с флагом -openssl, впрочем так и было до того

Попробовал собрать проект
%QTDIR%\examples\network\securesocketclient

Вылезла куча ошибок
Код

        link /LIBPATH:"d:\qt\lib" /NOLOGO /DEBUG /SUBSYSTEM:WINDOWS /OUT:debug\s
ecuresocketclient.exe @C:\DOCUME~1\dealer\LOCALS~1\Temp\nmF.tmp
certificateinfo.obj : error LNK2019: unresolved external symbol "__declspec(dlli
mport) public: class QString __thiscall QSslCertificate::subjectInfo(enum QSslCe
rtificate::SubjectInfo)const " (__imp_?subjectInfo@QSslCertificate@@QBE?AVQStrin
g@@W4SubjectInfo@1@@Z) referenced in function "public: void __thiscall Certifica
teInfo::setCertificateChain(class QList<class QSslCertificate> const &)" (?setCe
rtificateChain@CertificateInfo@@QAEXABV?$QList@VQSslCertificate@@@@@Z)
certificateinfo.obj : error LNK2019: unresolved external symbol "__declspec(dlli
mport) public: class QString __thiscall QSslCertificate::issuerInfo(enum QSslCer
tificate::SubjectInfo)const " (__imp_?issuerInfo@QSslCertificate@@QBE?AVQString@
@W4SubjectInfo@1@@Z) referenced in function "private: void __thiscall Certificat
eInfo::updateCertificateInfo(int)" (?updateCertificateInfo@CertificateInfo@@AAEX
H@Z)
certificateinfo.obj : error LNK2019: unresolved external symbol "__declspec(dlli
mport) public: __thiscall QSslCertificate::QSslCertificate(class QSslCertificate
 const &)" (__imp_??0QSslCertificate@@QAE@ABV0@@Z) referenced in function "priva
te: void __thiscall QList<class QSslCertificate>::node_copy(struct QList<class Q
SslCertificate>::Node *,struct QList<class QSslCertificate>::Node *,struct QList
<class QSslCertificate>::Node *)" (?node_copy@?$QList@VQSslCertificate@@@@AAEXPA
UNode@1@00@Z)
certificateinfo.obj : error LNK2019: unresolved external symbol "__declspec(dlli
mport) public: __thiscall QSslCertificate::~QSslCertificate(void)" (__imp_??1QSs
lCertificate@@QAE@XZ) referenced in function "public: void * __thiscall QSslCert
ificate::`scalar deleting destructor'(unsigned int)" (??_GQSslCertificate@@QAEPA
XI@Z)
sslclient.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
 public: __thiscall QSslCertificate::~QSslCertificate(void)" (__imp_??1QSslCerti
ficate@@QAE@XZ)
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) publ
ic: static bool __cdecl QSslSocket::supportsSsl(void)" (__imp_?supportsSsl@QSslS
ocket@@SA_NXZ) referenced in function _main
sslclient.obj : error LNK2001: unresolved external symbol "protected: virtual __
int64 __thiscall QSslSocket::writeData(char const *,__int64)" (?writeData@QSslSo
cket@@MAE_JPBD_J@Z)
sslclient.obj : error LNK2001: unresolved external symbol "protected: virtual __
int64 __thiscall QSslSocket::readData(char *,__int64)" (?readData@QSslSocket@@MA
E_JPAD_J@Z)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual bool
__thiscall QSslSocket::waitForBytesWritten(int)" (?waitForBytesWritten@QSslSocke
t@@UAE_NH@Z)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual bool
__thiscall QSslSocket::waitForReadyRead(int)" (?waitForReadyRead@QSslSocket@@UAE
_NH@Z)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual bool
__thiscall QSslSocket::canReadLine(void)const " (?canReadLine@QSslSocket@@UBE_NX
Z)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual __int
64 __thiscall QSslSocket::bytesToWrite(void)const " (?bytesToWrite@QSslSocket@@U
BE_JXZ)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual __int
64 __thiscall QSslSocket::bytesAvailable(void)const " (?bytesAvailable@QSslSocke
t@@UBE_JXZ)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual bool
__thiscall QSslSocket::atEnd(void)const " (?atEnd@QSslSocket@@UBE_NXZ)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual void
__thiscall QSslSocket::close(void)" (?close@QSslSocket@@UAEXXZ)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual int _
_thiscall QSslSocket::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_met
acall@QSslSocket@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual void
* __thiscall QSslSocket::qt_metacast(char const *)" (?qt_metacast@QSslSocket@@UA
EPAXPBD@Z)
sslclient.obj : error LNK2001: unresolved external symbol "public: virtual struc
t QMetaObject const * __thiscall QSslSocket::metaObject(void)const " (?metaObjec
t@QSslSocket@@UBEPBUQMetaObject@@XZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: void __thiscall QSslSocket::connectToHostEncrypted(class QString const
&,unsigned short,class QFlags<enum QIODevice::OpenModeFlag>)" (__imp_?connectToH
ostEncrypted@QSslSocket@@QAEXABVQString@@GV?$QFlags@W4OpenModeFlag@QIODevice@@@@
@Z) referenced in function "private: void __thiscall SslClient::secureConnect(vo
id)" (?secureConnect@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: __thiscall QSslSocket::QSslSocket(class QObject *)" (__imp_??0QSslSocke
t@@QAE@PAVQObject@@@Z) referenced in function "private: void __thiscall SslClien
t::secureConnect(void)" (?secureConnect@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: virtual __thiscall QSslSocket::~QSslSocket(void)" (__imp_??1QSslSocket@
@UAE@XZ) referenced in function "public: virtual void * __thiscall QSslSocket::`
scalar deleting destructor'(unsigned int)" (??_GQSslSocket@@UAEPAXI@Z)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: __thiscall QSslCipher::~QSslCipher(void)" (__imp_??1QSslCipher@@QAE@XZ)
 referenced in function "private: void __thiscall SslClient::socketEncrypted(voi
d)" (?socketEncrypted@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: int __thiscall QSslCipher::supportedBits(void)const " (__imp_?supported
Bits@QSslCipher@@QBEHXZ) referenced in function "private: void __thiscall SslCli
ent::socketEncrypted(void)" (?socketEncrypted@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: int __thiscall QSslCipher::usedBits(void)const " (__imp_?usedBits@QSslC
ipher@@QBEHXZ) referenced in function "private: void __thiscall SslClient::socke
tEncrypted(void)" (?socketEncrypted@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: class QString __thiscall QSslCipher::authenticationMethod(void)const "
(__imp_?authenticationMethod@QSslCipher@@QBE?AVQString@@XZ) referenced in functi
on "private: void __thiscall SslClient::socketEncrypted(void)" (?socketEncrypted
@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: class QString __thiscall QSslCipher::name(void)const " (__imp_?name@QSs
lCipher@@QBE?AVQString@@XZ) referenced in function "private: void __thiscall Ssl
Client::socketEncrypted(void)" (?socketEncrypted@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: class QSslCipher __thiscall QSslSocket::sessionCipher(void)const " (__i
mp_?sessionCipher@QSslSocket@@QBE?AVQSslCipher@@XZ) referenced in function "priv
ate: void __thiscall SslClient::socketEncrypted(void)" (?socketEncrypted@SslClie
nt@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: void __thiscall QSslSocket::ignoreSslErrors(void)" (__imp_?ignoreSslErr
ors@QSslSocket@@QAEXXZ) referenced in function "private: void __thiscall SslClie
nt::sslErrors(class QList<class QSslError> const &)" (?sslErrors@SslClient@@AAEX
ABV?$QList@VQSslError@@@@@Z)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: class QString __thiscall QSslError::errorString(void)const " (__imp_?er
rorString@QSslError@@QBE?AVQString@@XZ) referenced in function "private: void __
thiscall SslClient::sslErrors(class QList<class QSslError> const &)" (?sslErrors
@SslClient@@AAEXABV?$QList@VQSslError@@@@@Z)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: class QList<class QSslCertificate> __thiscall QSslSocket::peerCertifica
teChain(void)const " (__imp_?peerCertificateChain@QSslSocket@@QBE?AV?$QList@VQSs
lCertificate@@@@XZ) referenced in function "private: void __thiscall SslClient::
displayCertificateInfo(void)" (?displayCertificateInfo@SslClient@@AAEXXZ)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: __thiscall QSslError::QSslError(class QSslError const &)" (__imp_??0QSs
lError@@QAE@ABV0@@Z) referenced in function "private: void __thiscall QList<clas
s QSslError>::node_copy(struct QList<class QSslError>::Node *,struct QList<class
 QSslError>::Node *,struct QList<class QSslError>::Node *)" (?node_copy@?$QList@
VQSslError@@@@AAEXPAUNode@1@00@Z)
sslclient.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
 public: __thiscall QSslError::~QSslError(void)" (__imp_??1QSslError@@QAE@XZ) re
ferenced in function "public: void * __thiscall QSslError::`scalar deleting dest
ructor'(unsigned int)" (??_GQSslError@@QAEPAXI@Z)
debug\securesocketclient.exe : fatal error LNK1120: 31 unresolved externals
NMAKE : fatal error U1077: 'link' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio .NET 2003\
VC7\BIN\nmake.exe"' : return code '0x2'
Stop.


Какую либу забыл подключить ?
QtNetwork включена

Автор: neosapient 4.7.2008, 15:20
Скачал и установил http://www.slproweb.com/download/Win32OpenSSL-0_9_8g.exe  

переконфигурировал QT
configure -openssl -I c:\openssl\include -L c:\openssl\lib

собираю пример

Код

#include <QtNetwork>
#include <QtCore>
#include <QSslSocket>

int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    QSslSocket socket;
    //socket.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, "130.226.169.133", 3128));
    socket.connectToHostEncrypted("www.paypal.com", 443);
    socket.write("GET / HTTP/1.0\r\n\r\n");
    while (socket.waitForReadyRead())
        qDebug() << socket.readAll().data();
}


появляются ошибки не найденной библиотеки
Код

Compiling...
main.cpp
Linking...
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QSslSocket::~QSslSocket(void)" (__imp_??1QSslSocket@@UAE@XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall QSslSocket::waitForReadyRead(int)" (__imp_?waitForReadyRead@QSslSocket@@UAE_NH@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QSslSocket::connectToHostEncrypted(class QString const &,unsigned short,class QFlags)" (__imp_?connectToHostEncrypted@QSslSocket@@QAEXABVQString@@GV?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QSslSocket::QSslSocket(class QObject *)" (__imp_??0QSslSocket@@QAE@PAVQObject@@@Z) referenced in function _main
debug\main.exe : fatal error LNK1120: 4 unresolved externals


Что требуется подключить, чтобы собрать exe-шник ?

Пример прикреплен в архиве

Автор: neosapient 4.7.2008, 23:59
Windows XP, VC7, QT 4.3.4
----------------
Цитата

Compiling...
main.cpp
Linking...
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QSslSocket::~QSslSocket(void)" (__imp_??1QSslSocket@@UAE@XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall QSslSocket::waitForReadyRead(int)" (__imp_?waitForReadyRead@QSslSocket@@UAE_NH@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QSslSocket::connectToHostEncrypted(class QString const &,unsigned short,class QFlags)" (__imp_?connectToHostEncrypted@QSslSocket@@QAEXABVQString@@GV?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QSslSocket::QSslSocket(class QObject *)" (__imp_??0QSslSocket@@QAE@PAVQObject@@@Z) referenced in function _main
debug\main.exe : fatal error LNK1120: 4 unresolved externals


Тут нашел ответ на ошибку не найденой QtNetworkd.lib / QtNetworkd4.lib
http://prog.org.ru/forum/index.php/topic,6281.0.html


Надо скоректировать строки 
%QTDIR%\src\network\network.pro

Код

... выяснилось, что надо отредактировать network.pro, т.к. линкёр не находит ssleay32.obj и libeay32.obj (потому что их и нету):

Есть:

Code:
        win32:LIBS += ssleay32 libeay32А надо:

Code:
        win32:LIBS += ssleay32.lib libeay32.lib


Затем следует пересобрать QtNetworkd.lib / QtNetworkd4.lib

Автор: neosapient 5.7.2008, 10:50
Вроде получилось

httprequest.h
Код

#include <QDialog>

class QHttp;
class QSslSocket;

class HttpRequest : public QObject
{
    Q_OBJECT

    public:
        HttpRequest();
    void get(QString dstUrl, QString Login, QString Password);
    private slots:
        void httpRequestStarted(int requestId);
        void httpRequestFinished(int requestId, bool error);

    private:
        QHttp *http;
        QSslSocket *socket;
        int httpGetId;
};



httprequest.cpp
Код

#include <iostream>
#include <QtGui>
#include <QtNetwork>

#include "httprequest.h"

HttpRequest::HttpRequest()
    : QObject()
{
    http = new QHttp(this);
    socket = new QSslSocket(this);

    connect(http, SIGNAL(requestFinished(int, bool)),
                this, SLOT(httpRequestFinished(int, bool)));
    connect(http, SIGNAL(requestStarted(int)),
                this, SLOT(httpRequestStarted(int)));
}

void HttpRequest::get(QString dstUrl, QString Login, QString Password)
{
    QUrl url(dstUrl);

    printf("port is %d\n", url.port());

    http->setSocket(socket);
    http->setUser(Login,Password);
    http->setHost(url.host(), QHttp::ConnectionModeHttps, url.port() != -1 ? url.port() : 443);
    //http->setProxy ( ProxyIP, ProxyPort, ProxyLogin, ProxyPassword) ;

    httpGetId = http->get(url.path());
}

void HttpRequest::httpRequestStarted(int id)
{
    printf("started request #%d\n", id);
}

void HttpRequest::httpRequestFinished(int requestId, bool error)
{
    if (requestId != httpGetId) {
        return;
    }
    printf("finished request #%d\n", requestId);

    if (error) {
        printf("%s\n", http->errorString());
    } 
    else {
        QString *str = new QString(http->readAll());
        QChar *data = str->data();
        while (*data != 0) {
            std::cout << (char *) data;
            ++data;
            }
        printf("\n");
    }
    exit(1);
}



main.cpp
Код

#include <QtGui>
#include <QtNetwork>
#include <QCoreApplication>

#include "httprequest.h"

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    HttpRequest request;
    request.get("https://www.someurl.com:443/sometext.htm", "login", "password" );

    return app.exec();
}


main.pro
Код

######################################################################
# Automatically generated by qmake (2.01a) ?? 3. ??? 13:38:59 2008
######################################################################

TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .
QT += network
CONFIG += qt console


# Input
HEADERS += httprequest.h
SOURCES += httprequest.cpp main.cpp

Автор: neosapient 5.7.2008, 11:08
Ещё вопрос, чтоб завершить тему.

Код я представил в посте выше.
Надо научиться обрабатывать ошибки SSL. 

Я правильон понимаю, что следует подключить обработку ошибки 
от QSslSocket *socket сигнала SIGNAL(sslErrors ( const QList<QSslError> & errors ) 
на QHttp *http слот ignoreSslErrors()
Код

    connect(socket, SIGNAL(sslErrors ( const QList<QSslError> & errors ) ),
                http, SLOT(ignoreSslErrors()));


Либо из-за того , что сокет ssl передан объекту qhttp, то от QHttp *http
сигнал SIGNAL(sslErrors ( const QList<QSslError> & errors ) будет приходить 
на слот ignoreSslErrors()
Код

    connect(http, SIGNAL(sslErrors ( const QList<QSslError> & errors ) ),
                http, SLOT(ignoreSslErrors()));


Откуда приходит сигнал ? Какая форма записи будет правильной ?

Автор: neosapient 4.8.2008, 14:56
Добрый день.

Простите, что вновь поднимаю эту ветку форума, но по непонятной мне причине программа перестала работать.

Пример программы приведен двумя постами выше, ничего не менял. Логин и пароль ввожу правильно. Если открываю страницу браузером, то проблем нет.

Программа подключается к указаному серверу. Висит секунд 5-10, затем вызавается
void HttpRequest::httpRequestFinished(int requestId, bool error)

В переменной error - стоит флаг true.

Распечатываю ошибки
        qDebug() << http->errorString();
        qDebug() << socket->errorString();
Мне печатается "Host not found"

Как избавиться от косяка ?

Автор: SABROG 4.8.2008, 16:46
Название хоста передаешь с "http" ?

Автор: neosapient 4.8.2008, 19:33
>> Название хоста передаешь с "http" ?

Название хоста ввожу с "https" 

---------------------------
Сейчас начинаю думать в сторону загружености сети

С утра всё работало.
Днем не работает, хотя страницу возможно вытянуть через браузер.
Сейчас (к концу вечера) опять работает.

Может можно как либо повысить приоретет запроса старицы (хотя подозреваю что вопрос абсурдный)
Итак, код не менял, а прога то работает, то нет. Думаю, что все зависит от загружености сети. 
Можно ли как-либо управлять ситуацией, чтоб страница грузилась?

Автор: SABROG 4.8.2008, 20:36
Цитата(neosapient @  4.8.2008,  19:33 Найти цитируемый пост)
>> Название хоста передаешь с "http" ?

Название хоста ввожу с "https" 


Надо без (для метода setHost).

Автор: neosapient 7.8.2008, 14:38
Цитата

Надо без (для метода setHost).

Попробовал "www.someurl.com/sometext.htm"
Если работать без "http" или "https", то сразу выдается сообщение с ошибкой
"No server set to connect to"


Автор: SABROG 7.8.2008, 15:00
Цитата

Попробовал "www.someurl.com/sometext.htm"


Дык извините, вы имя хоста передаете или Url ? Only "www.someurl.com" без /sometext.htm тогда.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)