1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Remove interceptor and fix some errors related with shares

This commit is contained in:
agarcia 2020-07-02 12:42:21 +02:00
parent b287cb9148
commit c5891b0a14
8 changed files with 7 additions and 70 deletions

View File

@ -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<String, List<Cookie>> 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;
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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<String, String?>?,
callback: DavResponseCallback,
rawCallback: (response: Response) -> Unit

View File

@ -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) {

View File

@ -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")

View File

@ -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")

View File

@ -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}")