From e0e6d3da4944172a05d6840e9d1e902fba8eb90d Mon Sep 17 00:00:00 2001 From: davigonz Date: Wed, 18 Jul 2018 11:49:06 +0200 Subject: [PATCH] Use callback to get okhttp response --- .../owncloud/android/lib/common/OwnCloudClient.java | 2 -- .../lib/common/http/methods/webdav/DavMethod.java | 6 ++---- .../common/http/methods/webdav/PropfindMethod.java | 12 ++++++------ .../files/ExistenceCheckRemoteOperation.java | 1 - 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/com/owncloud/android/lib/common/OwnCloudClient.java b/src/com/owncloud/android/lib/common/OwnCloudClient.java index d67fee6e..3aba71d9 100644 --- a/src/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/src/com/owncloud/android/lib/common/OwnCloudClient.java @@ -175,8 +175,6 @@ public class OwnCloudClient extends HttpClient { return status; } - - public RedirectionPath followRedirection(HttpBaseMethod method) throws Exception { int redirectionsCount = 0; int status = method.getStatusCode(); diff --git a/src/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java b/src/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java index 1c827b88..bf926d63 100644 --- a/src/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java +++ b/src/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java @@ -24,7 +24,6 @@ package com.owncloud.android.lib.common.http.methods.webdav; -import com.owncloud.android.lib.common.http.HttpClient; import com.owncloud.android.lib.common.http.methods.HttpBaseMethod; import java.net.URL; @@ -32,7 +31,6 @@ import java.util.concurrent.TimeUnit; import at.bitfire.dav4android.Constants; import at.bitfire.dav4android.DavOCResource; -import at.bitfire.dav4android.DavResource; import at.bitfire.dav4android.exception.RedirectException; import okhttp3.HttpUrl; @@ -61,8 +59,8 @@ public abstract class DavMethod extends HttpBaseMethod { @Override public int execute() throws Exception { try { - return onExecute(); - } catch(RedirectException e) { + return onExecute(); + } catch (RedirectException e) { return getStatusCode(); } } diff --git a/src/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java b/src/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java index 7962427b..fd4590b0 100644 --- a/src/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java +++ b/src/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.List; + import at.bitfire.dav4android.Property; import at.bitfire.dav4android.Response; import at.bitfire.dav4android.exception.DavException; @@ -71,18 +72,17 @@ public class PropfindMethod extends DavMethod { case OTHER: default: } - return Unit.INSTANCE; - }, response -> { - mResponse = response; - return Unit.INSTANCE; - }); + }, response -> { + mResponse = response; + return Unit.INSTANCE; + }); } catch (UnauthorizedException davException) { // Do nothing, we will use the 401 code to handle the situation return davException.getCode(); } - return super.getStatusCode(); + return getStatusCode(); } public int getDepth() { diff --git a/src/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java b/src/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java index 8e733995..4c6ad18f 100644 --- a/src/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java @@ -77,7 +77,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { @Override protected RemoteOperationResult run(OwnCloudClient client) { - try { client.setFollowRedirects(true); PropfindMethod propfindMethod = new PropfindMethod(