mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
Account: Send a X-Request-ID header #5853
This commit is contained in:
parent
5738110cb6
commit
1c2d5f16c8
2 changed files with 17 additions and 0 deletions
|
@ -33,6 +33,8 @@
|
|||
#include <QDir>
|
||||
#include <QSslKey>
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Q_LOGGING_CATEGORY(lcAccount, "sync.account", QtInfoMsg)
|
||||
|
@ -123,6 +125,13 @@ 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
|
||||
|
@ -155,6 +164,10 @@ 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
|
||||
|
@ -230,6 +243,7 @@ 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,6 +251,9 @@ 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
|
||||
|
|
Loading…
Reference in a new issue