* make qt configuration in CMake more flexible * move creating of symlinks on windows from post build event to cmake * create symlinks for test data in cmake on windows * switch to 7zip for extraction python indexer * make results of sourcegrouptests case insensitive
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#include "QtRequest.h"
|
|
|
|
#include <QNetworkAccessManager>
|
|
#include <QNetworkReply>
|
|
#include <qsslconfiguration.h>
|
|
|
|
#include "logging.h"
|
|
|
|
QtRequest::QtRequest()
|
|
{
|
|
m_networkManager = new QNetworkAccessManager(this);
|
|
QObject::connect(m_networkManager, &QNetworkAccessManager::finished, this, &QtRequest::finished);
|
|
}
|
|
|
|
void QtRequest::sendRequest(QString url)
|
|
{
|
|
LOG_INFO_STREAM(<< "send HTTP request: " << url.toStdString());
|
|
|
|
try
|
|
{
|
|
QNetworkRequest request;
|
|
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
|
request.setUrl(QUrl(url));
|
|
m_networkManager->get(request);
|
|
}
|
|
catch (...)
|
|
{
|
|
LOG_ERROR("Exception thrown while processing HTTP request.");
|
|
QByteArray bytes;
|
|
emit receivedData(bytes);
|
|
}
|
|
}
|
|
|
|
void QtRequest::finished(QNetworkReply* reply)
|
|
{
|
|
QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
|
QVariant redirectionTargetUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
|
|
|
Q_UNUSED(statusCodeV);
|
|
Q_UNUSED(redirectionTargetUrl);
|
|
|
|
if (reply->error() != QNetworkReply::NoError)
|
|
{
|
|
LOG_ERROR_STREAM(<< "An error occured during http request. ERRORCODE: " << reply->error());
|
|
}
|
|
|
|
QByteArray bytes = reply->readAll();
|
|
LOG_INFO_STREAM(<< "received HTTP reply: " << bytes.toStdString());
|
|
|
|
delete reply;
|
|
|
|
emit receivedData(bytes);
|
|
}
|