diff --git a/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java b/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java index 1a3aa7a01..41be33761 100644 --- a/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java +++ b/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java @@ -378,10 +378,10 @@ public RemoteOperationResult(boolean success, int httpCode, String httpPhrase, H Header current; for (Header httpHeader : httpHeaders) { current = httpHeader; - if (HEADER_LOCATION.equals(current.getName().toLowerCase(Locale.US))) { - mRedirectedLocation = current.getValue(); - } else if (HEADER_WWW_AUTHENTICATE.equals(current.getName().toLowerCase(Locale.US))) { + if (HEADER_WWW_AUTHENTICATE.equals(current.getName().toLowerCase(Locale.US))) { mAuthenticateHeaders.add(current.getValue()); + } else if (HEADER_LOCATION.equals(current.getName().toLowerCase(Locale.US)) && mAuthenticateHeaders.isEmpty()) { + mRedirectedLocation = current.getValue(); } } } diff --git a/src/test/java/com/owncloud/android/lib/common/operations/RemoteOperationResultTest.kt b/src/test/java/com/owncloud/android/lib/common/operations/RemoteOperationResultTest.kt index 7eb6e5439..5e705dbad 100644 --- a/src/test/java/com/owncloud/android/lib/common/operations/RemoteOperationResultTest.kt +++ b/src/test/java/com/owncloud/android/lib/common/operations/RemoteOperationResultTest.kt @@ -72,7 +72,7 @@ class RemoteOperationResultTest { ) Assert.assertEquals( "Wrong location header", - LOCATION_HEADER.value, + null, sut.redirectedLocation ) }