Merge branch 'master' into develop
[pub/Android/ownCloud.git] / src / com / owncloud / android / operations / DetectAuthenticationMethodOperation.java
index a30829b..c670316 100644 (file)
@@ -94,11 +94,13 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
         client.setFollowRedirects(false);
         
         // try to access the root folder, following redirections but not SAML SSO redirections
-        do {
+        result = operation.execute(client);
+        String redirectedLocation = result.getRedirectedLocation(); 
+        while (redirectedLocation != null && redirectedLocation.length() > 0 && !result.isIdPRedirection()) {
+            client.setWebdavUri(Uri.parse(result.getRedirectedLocation()));
             result = operation.execute(client);
-            client.setBaseUri(Uri.parse(result.getRedirectedLocation()));
-            
-        } while (result.isTemporalRedirection() && !result.isIdPRedirection());
+            redirectedLocation = result.getRedirectedLocation();
+        } 
 
         // analyze response  
         if (result.getCode() == ResultCode.UNAUTHORIZED) {