HTTPClass
::HTTPClass(QObject *parent
) :{
namConnection = new QNetworkAccessManager(this);
connect(namConnection, SIGNAL(finished(QNetworkReply*)),
this, SLOT(slotReplyFinished(QNetworkReply*)));
connect(namConnection, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
connect(namConnection,
SIGNAL(proxyAuthenticationRequired
(QNetworkProxy,QAuthenticator
*)),
this,
SLOT(slotProxyAuthenticationRequired
(QNetworkProxy,QAuthenticator
*)));
connect(namConnection, SIGNAL(networkSessionConnected()),
this, SLOT(slotNetworkSessionConnected()));
QNetworkRequest request;
request.
setUrl(QUrl("http://en.wikipedia.org/wiki/Main_Page"));
reply = namConnection->get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(slotError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(slotSslErrors(QList<QSslError>)));
}
void HTTPClass::setConnectionData()
{
}
void HTTPClass::slotReplyFinished(QNetworkReply *reply)
{
qDebug() << reply->readAll();
reply->deleteLater();
}
void HTTPClass::slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *aut)
{
qDebug() << "Ha";
//aut->setUser("Username");
//aut->setPassword("Password");
}
void HTTPClass
::slotProxyAuthenticationRequired(QNetworkProxy proxy, QAuthenticator
*aut
) {
}
void HTTPClass::slotNetworkSessionConnected()
{
qDebug() << "Connected";
}
void HTTPClass::slotReadyRead()
{
reply->readAll();
}
void HTTPClass::slotError(QNetworkReply::NetworkError error)
{
qDebug
() <<
QString::number(error
);
}
void HTTPClass::slotSslErrors(QList<QSslError> errors)
{
qDebug() << errors[0].errorString();
}
HTTPClass::HTTPClass(QObject *parent) :
QObject(parent)
{
namConnection = new QNetworkAccessManager(this);
connect(namConnection, SIGNAL(finished(QNetworkReply*)),
this, SLOT(slotReplyFinished(QNetworkReply*)));
connect(namConnection, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
connect(namConnection, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(slotProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
connect(namConnection, SIGNAL(networkSessionConnected()),
this, SLOT(slotNetworkSessionConnected()));
QNetworkRequest request;
request.setUrl(QUrl("http://en.wikipedia.org/wiki/Main_Page"));
reply = namConnection->get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(slotError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(slotSslErrors(QList<QSslError>)));
}
void HTTPClass::setConnectionData()
{
}
void HTTPClass::slotReplyFinished(QNetworkReply *reply)
{
qDebug() << reply->readAll();
reply->deleteLater();
}
void HTTPClass::slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *aut)
{
qDebug() << "Ha";
//aut->setUser("Username");
//aut->setPassword("Password");
}
void HTTPClass::slotProxyAuthenticationRequired(QNetworkProxy proxy, QAuthenticator *aut)
{
}
void HTTPClass::slotNetworkSessionConnected()
{
qDebug() << "Connected";
}
void HTTPClass::slotReadyRead()
{
reply->readAll();
}
void HTTPClass::slotError(QNetworkReply::NetworkError error)
{
qDebug() << QString::number(error);
}
void HTTPClass::slotSslErrors(QList<QSslError> errors)
{
qDebug() << errors[0].errorString();
}
To copy to clipboard, switch view to plain text mode
Bookmarks