From: Christian Kamm Date: Wed, 22 Feb 2017 12:04:26 +0000 (+0100) Subject: Wizard: Handle PROPFIND redirects #5553 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~797^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=21a09df7d11283a5c8e129630642cd2c49518340;p=nextcloud-desktop.git Wizard: Handle PROPFIND redirects #5553 By default, followRedirects is true for all requests, to transparently handle redirections. In the wizard, we have special redirect-handling code though and that was being skipped. Setting the flag to false allows the wizard to be aware of redirects and to handle them in the correct way. Tested with the server described in https://github.com/owncloud/administration/tree/master/redirectServer There's a second bug here, where followRedirects always converts redirected requests to the GET verb. That means redirected PROPFINDs will never have worked. This change un-breaks them for the wizard only. There should be no case that previously worked that stops working now. --- diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 24910f025..bf67c9acf 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -267,6 +267,9 @@ void OwncloudSetupWizard::testOwnCloudConnect() auto *job = new PropfindJob(account, "/", this); job->setIgnoreCredentialFailure(true); + // There is custom redirect handling in the error handler, + // so don't automatically follow redirects. + job->setFollowRedirects(false); job->setProperties(QList() << "getlastmodified"); connect(job, SIGNAL(result(QVariantMap)), _ocWizard, SLOT(successfulStep())); connect(job, SIGNAL(finishedWithError()), this, SLOT(slotAuthError())); diff --git a/src/libsync/abstractnetworkjob.cpp b/src/libsync/abstractnetworkjob.cpp index ab09786fc..eb865456b 100644 --- a/src/libsync/abstractnetworkjob.cpp +++ b/src/libsync/abstractnetworkjob.cpp @@ -93,6 +93,11 @@ void AbstractNetworkJob::setIgnoreCredentialFailure(bool ignore) _ignoreCredentialFailure = ignore; } +void AbstractNetworkJob::setFollowRedirects(bool follow) +{ + _followRedirects = follow; +} + void AbstractNetworkJob::setPath(const QString &path) { _path = path; diff --git a/src/libsync/abstractnetworkjob.h b/src/libsync/abstractnetworkjob.h index 6f7d3cbe5..272ee604f 100644 --- a/src/libsync/abstractnetworkjob.h +++ b/src/libsync/abstractnetworkjob.h @@ -54,6 +54,18 @@ public: void setIgnoreCredentialFailure(bool ignore); bool ignoreCredentialFailure() const { return _ignoreCredentialFailure; } + /** Whether to handle redirects transparently. + * + * If true, a follow-up request is issued automatically when + * a redirect is encountered. The finished() function is only + * called if there are no more redirects (or there are problems + * with the redirect). + * + * The transparent redirect following may be disabled for some + * requests where custom handling is necessary. + */ + void setFollowRedirects(bool follow); + QByteArray responseTimestamp(); qint64 timeoutMsec() { return _timer.interval(); }