aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-05-12 12:55:39 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-05-12 12:55:39 +0900
commitb459f1b3e5355b30a51e9d12a35d8aee6a842886 (patch)
treee1652527e84c96ce3e181bf46d6a44cb87f040d6
parentb91b6bca83935db2db949b683bbe584c05c477b6 (diff)
downloadlibquotient-b459f1b3e5355b30a51e9d12a35d8aee6a842886.tar.gz
libquotient-b459f1b3e5355b30a51e9d12a35d8aee6a842886.zip
BaseJob: Do not leak access token into the job configuration
Before the access token was added to Private::requestQuery on every sendRequest() invocation, leading to the same access token being added up to the request once more with each retry.
-rw-r--r--jobs/basejob.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp
index 3e2ecd54..c71616a6 100644
--- a/jobs/basejob.cpp
+++ b/jobs/basejob.cpp
@@ -125,9 +125,10 @@ void BaseJob::Private::sendRequest()
{
QUrl url = connection->baseUrl();
url.setPath( url.path() + "/" + apiEndpoint );
+ QUrlQuery q = requestQuery;
if (needsToken)
- requestQuery.addQueryItem("access_token", connection->accessToken());
- url.setQuery(requestQuery);
+ q.addQueryItem("access_token", connection->accessToken());
+ url.setQuery(q);
QNetworkRequest req {url};
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
@@ -234,6 +235,9 @@ void BaseJob::finishJob()
if ((error() == NetworkError || error() == TimeoutError)
&& d->retriesTaken < d->maxRetries)
{
+ // TODO: The whole retrying thing should be put to ConnectionManager
+ // otherwise independently retrying jobs make a bit of notification
+ // storm towards the UI.
const auto retryInterval = getNextRetryInterval();
++d->retriesTaken;
qCWarning(JOBS) << this << "will take retry" << d->retriesTaken