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:
parent
b287cb9148
commit
c5891b0a14
@ -26,7 +26,6 @@ package com.owncloud.android.lib.common.http;
|
|||||||
|
|
||||||
import android.content.Context;
|
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.AdvancedX509TrustManager;
|
||||||
import com.owncloud.android.lib.common.network.NetworkUtils;
|
import com.owncloud.android.lib.common.network.NetworkUtils;
|
||||||
import okhttp3.Cookie;
|
import okhttp3.Cookie;
|
||||||
@ -56,7 +55,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class HttpClient {
|
public class HttpClient {
|
||||||
private static OkHttpClient sOkHttpClient;
|
private static OkHttpClient sOkHttpClient;
|
||||||
private static HttpInterceptor sOkHttpInterceptor;
|
|
||||||
private static Context sContext;
|
private static Context sContext;
|
||||||
private static HashMap<String, List<Cookie>> sCookieStore = new HashMap<>();
|
private static HashMap<String, List<Cookie>> sCookieStore = new HashMap<>();
|
||||||
|
|
||||||
@ -112,7 +110,6 @@ public class HttpClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
|
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
|
||||||
.addInterceptor(getOkHttpInterceptor())
|
|
||||||
.protocols(Arrays.asList(Protocol.HTTP_1_1))
|
.protocols(Arrays.asList(Protocol.HTTP_1_1))
|
||||||
.readTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
.readTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||||
.writeTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
.writeTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||||
@ -132,13 +129,6 @@ public class HttpClient {
|
|||||||
return sOkHttpClient;
|
return sOkHttpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HttpInterceptor getOkHttpInterceptor() {
|
|
||||||
if (sOkHttpInterceptor == null) {
|
|
||||||
sOkHttpInterceptor = new HttpInterceptor();
|
|
||||||
}
|
|
||||||
return sOkHttpInterceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Context getContext() {
|
public Context getContext() {
|
||||||
return sContext;
|
return sContext;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -20,7 +20,7 @@ abstract class HttpBaseMethod constructor(url: URL) {
|
|||||||
var request: Request
|
var request: Request
|
||||||
var requestBody: RequestBody? = null
|
var requestBody: RequestBody? = null
|
||||||
lateinit var response: Response
|
lateinit var response: Response
|
||||||
var responseBodyString: String? = null
|
private var responseBodyString: String? = null
|
||||||
|
|
||||||
var call: Call? = null
|
var call: Call? = null
|
||||||
|
|
||||||
|
@ -289,8 +289,7 @@ class OCDavResource(
|
|||||||
@Throws(IOException::class, HttpException::class, DavException::class)
|
@Throws(IOException::class, HttpException::class, DavException::class)
|
||||||
fun propfind(
|
fun propfind(
|
||||||
depth: Int,
|
depth: Int,
|
||||||
vararg reqProp:
|
vararg reqProp: Property.Name,
|
||||||
Property.Name,
|
|
||||||
listOfHeaders: HashMap<String, String?>?,
|
listOfHeaders: HashMap<String, String?>?,
|
||||||
callback: DavResponseCallback,
|
callback: DavResponseCallback,
|
||||||
rawCallback: (response: Response) -> Unit
|
rawCallback: (response: Response) -> Unit
|
||||||
|
@ -131,7 +131,7 @@ class CreateRemoteShareOperation(
|
|||||||
parser.oneOrMoreSharesRequired = true
|
parser.oneOrMoreSharesRequired = true
|
||||||
parser.ownCloudVersion = client.ownCloudVersion
|
parser.ownCloudVersion = client.ownCloudVersion
|
||||||
parser.serverBaseUri = client.baseUri
|
parser.serverBaseUri = client.baseUri
|
||||||
result = parser.parse(postMethod.responseBodyString)
|
result = parser.parse(postMethod.getResponseBodyAsString())
|
||||||
|
|
||||||
if (result.isSuccess && retrieveShareDetails) {
|
if (result.isSuccess && retrieveShareDetails) {
|
||||||
// retrieve more info - POST only returns the index of the new share
|
// retrieve more info - POST only returns the index of the new share
|
||||||
@ -143,7 +143,7 @@ class CreateRemoteShareOperation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result = parser.parse(postMethod.responseBodyString)
|
result = parser.parse(postMethod.getResponseBodyAsString())
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -98,7 +98,7 @@ class GetRemoteShareesOperation
|
|||||||
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE)
|
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE)
|
||||||
|
|
||||||
val status = client.executeHttpMethod(getMethod)
|
val status = client.executeHttpMethod(getMethod)
|
||||||
val response = getMethod.responseBodyString
|
val response = getMethod.getResponseBodyAsString()
|
||||||
|
|
||||||
if (isSuccess(status)) {
|
if (isSuccess(status)) {
|
||||||
Timber.d("Successful response: $response")
|
Timber.d("Successful response: $response")
|
||||||
|
@ -86,7 +86,7 @@ class GetRemoteSharesForFileOperation(
|
|||||||
)
|
)
|
||||||
parser.ownCloudVersion = client.ownCloudVersion
|
parser.ownCloudVersion = client.ownCloudVersion
|
||||||
parser.serverBaseUri = client.baseUri
|
parser.serverBaseUri = client.baseUri
|
||||||
result = parser.parse(getMethod.responseBodyString)
|
result = parser.parse(getMethod.getResponseBodyAsString())
|
||||||
|
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
Timber.d("Got ${result.data.shares.size} shares")
|
Timber.d("Got ${result.data.shares.size} shares")
|
||||||
|
@ -73,7 +73,7 @@ class RemoveRemoteShareOperation(private val remoteShareId: Long) : RemoteOperat
|
|||||||
val parser = ShareToRemoteOperationResultParser(
|
val parser = ShareToRemoteOperationResultParser(
|
||||||
ShareXMLParser()
|
ShareXMLParser()
|
||||||
)
|
)
|
||||||
result = parser.parse(deleteMethod.responseBodyString)
|
result = parser.parse(deleteMethod.getResponseBodyAsString())
|
||||||
|
|
||||||
Timber.d("Unshare $remoteShareId: ${result.logMessage}")
|
Timber.d("Unshare $remoteShareId: ${result.logMessage}")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user