diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java index f9939385..12571a88 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java @@ -26,7 +26,6 @@ package com.owncloud.android.lib.common.http; import android.content.Context; -import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor; import com.owncloud.android.lib.common.network.AdvancedX509TrustManager; import com.owncloud.android.lib.common.network.NetworkUtils; import okhttp3.Cookie; @@ -56,7 +55,6 @@ import java.util.concurrent.TimeUnit; */ public class HttpClient { private static OkHttpClient sOkHttpClient; - private static HttpInterceptor sOkHttpInterceptor; private static Context sContext; private static HashMap> sCookieStore = new HashMap<>(); @@ -112,7 +110,6 @@ public class HttpClient { }; OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder() - .addInterceptor(getOkHttpInterceptor()) .protocols(Arrays.asList(Protocol.HTTP_1_1)) .readTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS) .writeTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS) @@ -132,13 +129,6 @@ public class HttpClient { return sOkHttpClient; } - private static HttpInterceptor getOkHttpInterceptor() { - if (sOkHttpInterceptor == null) { - sOkHttpInterceptor = new HttpInterceptor(); - } - return sOkHttpInterceptor; - } - public Context getContext() { return sContext; } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/HttpInterceptor.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/HttpInterceptor.java deleted file mode 100644 index b7e6b6c9..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/HttpInterceptor.java +++ /dev/null @@ -1,52 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2020 ownCloud GmbH. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -package com.owncloud.android.lib.common.http.interceptors; - -import okhttp3.Interceptor; -import okhttp3.Request; -import okhttp3.Response; -import org.jetbrains.annotations.NotNull; -import timber.log.Timber; - -import java.io.IOException; - -/** - * Http interceptor to use multiple interceptors in the same {@link okhttp3.OkHttpClient} instance - * - * @author David González Verdugo - */ -public class HttpInterceptor implements Interceptor { - - @NotNull - @Override - public Response intercept(Chain chain) throws IOException { - Request request = chain.request(); - - Timber.d("Executing in request headers %s", request.headers().toString()); - - return chain.proceed(request); - } - -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.kt index f29420d8..bf67caf6 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.kt @@ -20,7 +20,7 @@ abstract class HttpBaseMethod constructor(url: URL) { var request: Request var requestBody: RequestBody? = null lateinit var response: Response - var responseBodyString: String? = null + private var responseBodyString: String? = null var call: Call? = null diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/OCDavResource.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/OCDavResource.kt index d8a53583..7edf43f8 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/OCDavResource.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/OCDavResource.kt @@ -289,8 +289,7 @@ class OCDavResource( @Throws(IOException::class, HttpException::class, DavException::class) fun propfind( depth: Int, - vararg reqProp: - Property.Name, + vararg reqProp: Property.Name, listOfHeaders: HashMap?, callback: DavResponseCallback, rawCallback: (response: Response) -> Unit diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt index e188f7a7..896f570a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt @@ -131,7 +131,7 @@ class CreateRemoteShareOperation( parser.oneOrMoreSharesRequired = true parser.ownCloudVersion = client.ownCloudVersion parser.serverBaseUri = client.baseUri - result = parser.parse(postMethod.responseBodyString) + result = parser.parse(postMethod.getResponseBodyAsString()) if (result.isSuccess && retrieveShareDetails) { // retrieve more info - POST only returns the index of the new share @@ -143,7 +143,7 @@ class CreateRemoteShareOperation( } } else { - result = parser.parse(postMethod.responseBodyString) + result = parser.parse(postMethod.getResponseBodyAsString()) } } catch (e: Exception) { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt index c1ec316e..e3432b5b 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt @@ -98,7 +98,7 @@ class GetRemoteShareesOperation getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE) val status = client.executeHttpMethod(getMethod) - val response = getMethod.responseBodyString + val response = getMethod.getResponseBodyAsString() if (isSuccess(status)) { Timber.d("Successful response: $response") diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt index d58918e4..ea1d7e2a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt @@ -86,7 +86,7 @@ class GetRemoteSharesForFileOperation( ) parser.ownCloudVersion = client.ownCloudVersion parser.serverBaseUri = client.baseUri - result = parser.parse(getMethod.responseBodyString) + result = parser.parse(getMethod.getResponseBodyAsString()) if (result.isSuccess) { Timber.d("Got ${result.data.shares.size} shares") diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt index 0df2e332..5fa18169 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt @@ -73,7 +73,7 @@ class RemoveRemoteShareOperation(private val remoteShareId: Long) : RemoteOperat val parser = ShareToRemoteOperationResultParser( ShareXMLParser() ) - result = parser.parse(deleteMethod.responseBodyString) + result = parser.parse(deleteMethod.getResponseBodyAsString()) Timber.d("Unshare $remoteShareId: ${result.logMessage}")