aboutsummaryrefslogtreecommitdiff
path: root/jobs/basejob.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-02-05 22:30:59 +0900
committerGitHub <noreply@github.com>2018-02-05 22:30:59 +0900
commit898f0c73b4d76c091e48c5e767b94d6ad18f582f (patch)
tree965074fffd32cae0dba11c494ae65b3c67bef28b /jobs/basejob.cpp
parent818fbda8c43fa76ede72db2e941ec81fe093cc59 (diff)
parentf6b55a3c8fc60dd263954df3359027eff2ef1e18 (diff)
downloadlibquotient-898f0c73b4d76c091e48c5e767b94d6ad18f582f.tar.gz
libquotient-898f0c73b4d76c091e48c5e767b94d6ad18f582f.zip
Merge pull request #170 from QMatrixClient/kitsune-expose-download-urls
Expose download URLs
Diffstat (limited to 'jobs/basejob.cpp')
-rw-r--r--jobs/basejob.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp
index 2d0d8b1b..c35a7711 100644
--- a/jobs/basejob.cpp
+++ b/jobs/basejob.cpp
@@ -179,17 +179,22 @@ void BaseJob::setExpectedContentTypes(const QByteArrayList& contentTypes)
d->expectedContentTypes = contentTypes;
}
-void BaseJob::Private::sendRequest()
+QUrl BaseJob::makeRequestUrl(QUrl baseUrl,
+ const QString& path, const QUrlQuery& query)
{
- QUrl url = connection->baseUrl();
- QString path = url.path();
- if (!path.endsWith('/') && !apiEndpoint.startsWith('/'))
- path.push_back('/');
+ auto pathBase = baseUrl.path();
+ if (!pathBase.endsWith('/') && !path.startsWith('/'))
+ pathBase.push_back('/');
- url.setPath( path + apiEndpoint );
- url.setQuery(requestQuery);
+ baseUrl.setPath( pathBase + path );
+ baseUrl.setQuery(query);
+ return baseUrl;
+}
- QNetworkRequest req {url};
+void BaseJob::Private::sendRequest()
+{
+ QNetworkRequest req
+ { makeRequestUrl(connection->baseUrl(), apiEndpoint, requestQuery) };
if (!requestHeaders.contains("Content-Type"))
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
req.setRawHeader(QByteArray("Authorization"),