Parcourir la source

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.
Christian Kamm il y a 9 ans
Parent
commit
21a09df7d1

+ 3 - 0
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<QByteArray>() << "getlastmodified");
     connect(job, SIGNAL(result(QVariantMap)), _ocWizard, SLOT(successfulStep()));
     connect(job, SIGNAL(finishedWithError()), this, SLOT(slotAuthError()));

+ 5 - 0
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;

+ 12 - 0
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(); }