mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 07:19:42 -05:00
Fix compilation errors with old versions of qt.
This commit is contained in:
parent
728acb77cf
commit
e5f7c46838
@ -1,15 +1,19 @@
|
||||
|
||||
#include "NetworkRequest.h"
|
||||
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include <QString>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
|
||||
|
||||
namespace {
|
||||
QList<QPair<QString, QString>> createDefaultHeaders() {
|
||||
QList<QPair<QString, QString>> headers;
|
||||
headers.append(QPair{"User-Agent", "KeePassXC"});
|
||||
headers.append(QPair<QString, QString>("User-Agent", "KeePassXC"));
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
@ -35,16 +39,16 @@ namespace
|
||||
QString contentType;
|
||||
QHash<QString, QString> contentTypeParameters;
|
||||
// Parse content type
|
||||
auto tokens = contentTypeHeader.split(";", Qt::SkipEmptyParts);
|
||||
auto tokens = contentTypeHeader.split(";", QString::SkipEmptyParts);
|
||||
if(tokens.isEmpty()) {
|
||||
return {contentType, contentTypeParameters};
|
||||
return qMakePair(contentType, contentTypeParameters);
|
||||
}
|
||||
contentType = tokens[0].trimmed();
|
||||
for (int i = 1; i < tokens.size(); ++i) {
|
||||
auto parameterTokens = tokens[i].split("=");
|
||||
contentTypeParameters[parameterTokens[0].trimmed()] = parameterTokens[1].trimmed();
|
||||
}
|
||||
return {contentType, contentTypeParameters};
|
||||
return qMakePair(contentType, contentTypeParameters);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -252,7 +256,7 @@ NetworkRequestBuilder& NetworkRequestBuilder::setHeaders(QList<QPair<QString, QS
|
||||
if (std::none_of(m_headers.begin(), m_headers.end(), [](const auto& pair) {
|
||||
return pair.first == "User-Agent";
|
||||
})) {
|
||||
m_headers.append(QPair{"User-Agent", "KeePassXC"});
|
||||
m_headers.append(QPair<QString, QString>("User-Agent", "KeePassXC"));
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -288,3 +292,5 @@ NetworkRequestBuilder& NetworkRequestBuilder::setMaxRedirects(unsigned int maxRe
|
||||
m_maxRedirects = maxRedirects;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
@ -17,6 +17,10 @@
|
||||
#ifndef KEEPASSXC_NETWORKREQUEST_H
|
||||
#define KEEPASSXC_NETWORKREQUEST_H
|
||||
|
||||
#include "config-keepassx.h"
|
||||
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
@ -157,4 +161,6 @@ public:
|
||||
NetworkRequest build();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // KEEPASSXC_NETWORKREQUEST_H
|
||||
|
@ -12,7 +12,7 @@ using ContentTypeParameters_t = QHash<QString, QString>;
|
||||
Q_DECLARE_METATYPE(ContentTypeParameters_t);
|
||||
Q_DECLARE_METATYPE(std::chrono::milliseconds);
|
||||
|
||||
static constexpr auto TIMEOUT_GRACE_MS = 25;
|
||||
static constexpr auto TIMEOUT_GRACE_MS = 100;
|
||||
|
||||
void TestNetworkRequest::testNetworkRequest()
|
||||
{
|
||||
@ -45,13 +45,13 @@ void TestNetworkRequest::testNetworkRequest()
|
||||
// Create request
|
||||
NetworkRequest request = buildRequest(requestedURL).setManager(&manager).build();
|
||||
|
||||
QString actualContent;
|
||||
QByteArray actualContent;
|
||||
bool didError = false, didSucceed = false;
|
||||
|
||||
// Check request
|
||||
QSignalSpy spy(&request, &NetworkRequest::success);
|
||||
connect(&request, &NetworkRequest::success, [&actualContent, &didSucceed](QByteArray content) {
|
||||
actualContent = QString(content);
|
||||
actualContent = content;
|
||||
didSucceed = true;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user