зеркало из https://github.com/nextcloud/desktop.git
X-Request-ID: Send per request not per account #5853
This commit is contained in:
Родитель
bd107e133f
Коммит
1fb68e8711
|
@ -21,6 +21,7 @@
|
|||
#include <QNetworkCookie>
|
||||
#include <QNetworkCookieJar>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QUuid>
|
||||
|
||||
#include "cookiejar.h"
|
||||
#include "accessmanager.h"
|
||||
|
@ -59,6 +60,13 @@ void AccessManager::setRawCookie(const QByteArray &rawCookie, const QUrl &url)
|
|||
jar->setCookiesFromUrl(cookieList, url);
|
||||
}
|
||||
|
||||
static QByteArray generateRequestId()
|
||||
{
|
||||
// Use a UUID with the starting and ending curly brace removed.
|
||||
auto uuid = QUuid::createUuid().toByteArray();
|
||||
return uuid.mid(1, uuid.size() - 2);
|
||||
}
|
||||
|
||||
QNetworkReply *AccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
|
||||
{
|
||||
QNetworkRequest newRequest(request);
|
||||
|
@ -79,6 +87,12 @@ QNetworkReply *AccessManager::createRequest(QNetworkAccessManager::Operation op,
|
|||
if (verb == "PROPFIND") {
|
||||
newRequest.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml; charset=utf-8"));
|
||||
}
|
||||
|
||||
// Generate a new request id
|
||||
QByteArray requestId = generateRequestId();
|
||||
qInfo(lcAccessManager) << op << verb << newRequest.url().toString() << "has X-Request-ID" << requestId;
|
||||
newRequest.setRawHeader("X-Request-ID", requestId);
|
||||
|
||||
return QNetworkAccessManager::createRequest(op, newRequest, outgoingData);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include <QDir>
|
||||
#include <QSslKey>
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Q_LOGGING_CATEGORY(lcAccount, "sync.account", QtInfoMsg)
|
||||
|
@ -125,13 +123,6 @@ AbstractCredentials *Account::credentials() const
|
|||
return _credentials.data();
|
||||
}
|
||||
|
||||
static QByteArray generateRequestId()
|
||||
{
|
||||
// Use a UUID with the starting and ending curly brace removed.
|
||||
auto uuid = QUuid::createUuid().toByteArray();
|
||||
return uuid.mid(1, uuid.size() - 2);
|
||||
}
|
||||
|
||||
void Account::setCredentials(AbstractCredentials *cred)
|
||||
{
|
||||
// set active credential manager
|
||||
|
@ -164,10 +155,6 @@ void Account::setCredentials(AbstractCredentials *cred)
|
|||
SLOT(slotCredentialsFetched()));
|
||||
connect(_credentials.data(), SIGNAL(asked()),
|
||||
SLOT(slotCredentialsAsked()));
|
||||
|
||||
// Generate a new request id
|
||||
_requestId = generateRequestId();
|
||||
qCInfo(lcAccount) << "Account for" << url() << "has X-Request-ID" << _requestId;
|
||||
}
|
||||
|
||||
QUrl Account::davUrl() const
|
||||
|
@ -243,7 +230,6 @@ QNetworkReply *Account::sendRequest(const QByteArray &verb, const QUrl &url, QNe
|
|||
{
|
||||
req.setUrl(url);
|
||||
req.setSslConfiguration(this->getOrCreateSslConfig());
|
||||
req.setRawHeader("X-Request-ID", _requestId);
|
||||
if (verb == "HEAD" && !data) {
|
||||
return _am->head(req);
|
||||
} else if (verb == "GET" && !data) {
|
||||
|
|
|
@ -251,9 +251,6 @@ private:
|
|||
/// Certificates that were explicitly rejected by the user
|
||||
QList<QSslCertificate> _rejectedCertificates;
|
||||
|
||||
/// X-Request-ID to send in network requests
|
||||
QByteArray _requestId;
|
||||
|
||||
static QString _configFileName;
|
||||
|
||||
QString _davPath; // defaults to value from theme, might be overwritten in brandings
|
||||
|
|
Загрузка…
Ссылка в новой задаче