Wizard: Handle PROPFIND redirects #5553
authorChristian Kamm <mail@ckamm.de>
Wed, 22 Feb 2017 12:04:26 +0000 (13:04 +0100)
committerckamm <mail@ckamm.de>
Wed, 22 Feb 2017 12:24:13 +0000 (13:24 +0100)
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.

src/gui/owncloudsetupwizard.cpp
src/libsync/abstractnetworkjob.cpp
src/libsync/abstractnetworkjob.h

index 24910f025a3fdc70b70bcf0420f965b1e99a5da6..bf67c9acfb800d8e705e7853832513db4c955dae 100644 (file)
@@ -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<QByteArray>() << "getlastmodified");
     connect(job, SIGNAL(result(QVariantMap)), _ocWizard, SLOT(successfulStep()));
     connect(job, SIGNAL(finishedWithError()), this, SLOT(slotAuthError()));
index ab09786fc6325272fe099f2f7ee83c19cbee4b6f..eb865456be03a1eb27a1e8533f0caae3d9cb84a2 100644 (file)
@@ -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;
index 6f7d3cbe56ab56c9f41e6ef08c6b7093217ddd94..272ee604f4748726ab3034e5fd5ba2cacf0d0161 100644 (file)
@@ -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(); }