diff --git a/src/core/NetworkRequest.cpp b/src/core/NetworkRequest.cpp index a6b98a9d8..dece08ffb 100644 --- a/src/core/NetworkRequest.cpp +++ b/src/core/NetworkRequest.cpp @@ -1,15 +1,19 @@ #include "NetworkRequest.h" + +#ifdef WITH_XC_NETWORKING + #include "NetworkManager.h" #include #include #include #include + namespace { QList> createDefaultHeaders() { QList> headers; - headers.append(QPair{"User-Agent", "KeePassXC"}); + headers.append(QPair("User-Agent", "KeePassXC")); return headers; } } @@ -35,16 +39,16 @@ namespace QString contentType; QHash 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("User-Agent", "KeePassXC")); } return *this; @@ -288,3 +292,5 @@ NetworkRequestBuilder& NetworkRequestBuilder::setMaxRedirects(unsigned int maxRe m_maxRedirects = maxRedirects; return *this; } + +#endif \ No newline at end of file diff --git a/src/core/NetworkRequest.h b/src/core/NetworkRequest.h index 0466e927f..ded416202 100644 --- a/src/core/NetworkRequest.h +++ b/src/core/NetworkRequest.h @@ -17,6 +17,10 @@ #ifndef KEEPASSXC_NETWORKREQUEST_H #define KEEPASSXC_NETWORKREQUEST_H +#include "config-keepassx.h" + +#ifdef WITH_XC_NETWORKING + #include #include #include @@ -157,4 +161,6 @@ public: NetworkRequest build(); }; +#endif + #endif // KEEPASSXC_NETWORKREQUEST_H diff --git a/tests/TestNetworkRequest.cpp b/tests/TestNetworkRequest.cpp index efc952ee9..3c0883f9b 100644 --- a/tests/TestNetworkRequest.cpp +++ b/tests/TestNetworkRequest.cpp @@ -12,7 +12,7 @@ using ContentTypeParameters_t = QHash; 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; });