mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Get rid of OkHttp dependencies in OwnCloudClient
This commit is contained in:
		
							parent
							
								
									f5795d1c03
								
							
						
					
					
						commit
						1631b9b55a
					
				| @ -33,8 +33,6 @@ import android.net.Uri; | |||||||
| import com.owncloud.android.lib.common.authentication.OwnCloudCredentials; | import com.owncloud.android.lib.common.authentication.OwnCloudCredentials; | ||||||
| import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory; | import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory; | ||||||
| import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials; | import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials; | ||||||
| import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor; |  | ||||||
| import com.owncloud.android.lib.common.http.interceptors.UserAgentInterceptor; |  | ||||||
| import com.owncloud.android.lib.common.http.HttpBaseMethod; | import com.owncloud.android.lib.common.http.HttpBaseMethod; | ||||||
| import com.owncloud.android.lib.common.network.RedirectionPath; | import com.owncloud.android.lib.common.network.RedirectionPath; | ||||||
| import com.owncloud.android.lib.common.utils.Log_OC; | import com.owncloud.android.lib.common.utils.Log_OC; | ||||||
| @ -55,10 +53,6 @@ import org.apache.commons.httpclient.params.HttpParams; | |||||||
| 
 | 
 | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| import java.util.Arrays; |  | ||||||
| 
 |  | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| import okhttp3.Protocol; |  | ||||||
| 
 | 
 | ||||||
| public class OwnCloudClient extends HttpClient { | public class OwnCloudClient extends HttpClient { | ||||||
| 
 | 
 | ||||||
| @ -103,9 +97,6 @@ public class OwnCloudClient extends HttpClient { | |||||||
| 
 | 
 | ||||||
|     private String mRedirectedLocation; |     private String mRedirectedLocation; | ||||||
| 
 | 
 | ||||||
|     private static OkHttpClient mOkHttpClient = null; |  | ||||||
|     private static HttpInterceptor mOkHttpInterceptor = null; |  | ||||||
| 
 |  | ||||||
|     /** |     /** | ||||||
|      * Constructor |      * Constructor | ||||||
|      */ |      */ | ||||||
| @ -144,14 +135,6 @@ public class OwnCloudClient extends HttpClient { | |||||||
| 
 | 
 | ||||||
|         super(connectionMgr); |         super(connectionMgr); | ||||||
| 
 | 
 | ||||||
|         if (mOkHttpClient == null) { |  | ||||||
|             mOkHttpClient = new OkHttpClient.Builder() |  | ||||||
|                     .addInterceptor(getBaseOkHttpInterceptor()) |  | ||||||
|                     .protocols(Arrays.asList(Protocol.HTTP_1_1)) |  | ||||||
|                     .followRedirects(false) |  | ||||||
|                     .build(); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (baseUri == null) { |         if (baseUri == null) { | ||||||
|             throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL"); |             throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL"); | ||||||
|         } |         } | ||||||
| @ -172,24 +155,6 @@ public class OwnCloudClient extends HttpClient { | |||||||
|         clearCredentials(); |         clearCredentials(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * {@link HttpInterceptor} singleton |  | ||||||
|      * @return {@link HttpInterceptor} instance with user agent |  | ||||||
|      */ |  | ||||||
|     public HttpInterceptor getBaseOkHttpInterceptor() { |  | ||||||
| 
 |  | ||||||
|         if (mOkHttpInterceptor == null) { |  | ||||||
|             mOkHttpInterceptor = new HttpInterceptor(). |  | ||||||
|                     addRequestInterceptor( |  | ||||||
|                             new UserAgentInterceptor( |  | ||||||
|                                     OwnCloudClientManagerFactory.getUserAgent() |  | ||||||
|                             ) |  | ||||||
|                     ); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         return mOkHttpInterceptor; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     private void applyProxySettings() { |     private void applyProxySettings() { | ||||||
|         String proxyHost = System.getProperty("http.proxyHost"); |         String proxyHost = System.getProperty("http.proxyHost"); | ||||||
|         String proxyPortSt = System.getProperty("http.proxyPort"); |         String proxyPortSt = System.getProperty("http.proxyPort"); | ||||||
| @ -291,9 +256,10 @@ public class OwnCloudClient extends HttpClient { | |||||||
| 
 | 
 | ||||||
|             checkFirstRedirection(method); |             checkFirstRedirection(method); | ||||||
| 
 | 
 | ||||||
|             if (mOkHttpClient.followRedirects()) { |             // TODO | ||||||
|                 status = followRedirection(method).getLastStatus(); | //            if (mOkHttpClient.followRedirects()) { | ||||||
|             } | //                status = followRedirection(method).getLastStatus(); | ||||||
|  | //            } | ||||||
| 
 | 
 | ||||||
|             repeatWithFreshCredentials = checkUnauthorizedAccess(status, repeatCounter); |             repeatWithFreshCredentials = checkUnauthorizedAccess(status, repeatCounter); | ||||||
|             if (repeatWithFreshCredentials) { |             if (repeatWithFreshCredentials) { | ||||||
| @ -483,18 +449,6 @@ public class OwnCloudClient extends HttpClient { | |||||||
|         return mCredentials; |         return mCredentials; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setFollowRedirects(boolean followRedirects) { |  | ||||||
|         mOkHttpClient |  | ||||||
|                 .newBuilder() |  | ||||||
|                 .followRedirects(followRedirects) |  | ||||||
|                 .followSslRedirects(followRedirects) |  | ||||||
|                 .build(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public boolean getFollowRedirects() { |  | ||||||
|         return mOkHttpClient.followRedirects(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     private void logCookiesAtRequest(Header[] headers, String when) { |     private void logCookiesAtRequest(Header[] headers, String when) { | ||||||
|         int counter = 0; |         int counter = 0; | ||||||
|         for (int i = 0; i < headers.length; i++) { |         for (int i = 0; i < headers.length; i++) { | ||||||
| @ -597,10 +551,6 @@ public class OwnCloudClient extends HttpClient { | |||||||
|         return mAccount; |         return mAccount; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public OkHttpClient getOkHttpClient() { |  | ||||||
|         return mOkHttpClient; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |     /** | ||||||
|      * Enables or disables silent refresh of credentials, if supported by credentials themselves. |      * Enables or disables silent refresh of credentials, if supported by credentials themselves. | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -40,6 +40,7 @@ import android.os.Bundle; | |||||||
| import com.owncloud.android.lib.common.accounts.AccountTypeUtils; | import com.owncloud.android.lib.common.accounts.AccountTypeUtils; | ||||||
| import com.owncloud.android.lib.common.accounts.AccountUtils; | import com.owncloud.android.lib.common.accounts.AccountUtils; | ||||||
| import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; | import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; | ||||||
|  | import com.owncloud.android.lib.common.http.HttpClient; | ||||||
| import com.owncloud.android.lib.common.network.NetworkUtils; | import com.owncloud.android.lib.common.network.NetworkUtils; | ||||||
| import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory; | import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory; | ||||||
| import com.owncloud.android.lib.common.utils.Log_OC; | import com.owncloud.android.lib.common.utils.Log_OC; | ||||||
| @ -175,11 +176,13 @@ public class OwnCloudClientFactory { | |||||||
|          |          | ||||||
|         OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager()); |         OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager()); | ||||||
|         client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); |         client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); | ||||||
|         client.setFollowRedirects(followRedirects); | 
 | ||||||
|  |         HttpClient.getOkHttpClient() | ||||||
|  |                 .newBuilder() | ||||||
|  |                 .followRedirects(followRedirects); | ||||||
|  | 
 | ||||||
|         client.setContext(context); |         client.setContext(context); | ||||||
|          |          | ||||||
|         return client; |         return client; | ||||||
|     } |     } | ||||||
|      |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
| @ -45,7 +45,7 @@ import com.owncloud.android.lib.common.utils.Log_OC; | |||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Implementation of {@link OwnCloudClientManager} |  * Implementation of {@link OwnCloudClientManager} | ||||||
|  * <p> |  * | ||||||
|  * TODO check multithreading safety |  * TODO check multithreading safety | ||||||
|  * |  * | ||||||
|  * @author David A. Velasco |  * @author David A. Velasco | ||||||
| @ -232,8 +232,5 @@ public class SingleSessionManager implements OwnCloudClientManager { | |||||||
|         if (!recentUri.equals(reusedClient.getBaseUri())) { |         if (!recentUri.equals(reusedClient.getBaseUri())) { | ||||||
|             reusedClient.setBaseUri(recentUri); |             reusedClient.setBaseUri(recentUri); | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
| @ -24,6 +24,7 @@ | |||||||
| package com.owncloud.android.lib.common.authentication; | package com.owncloud.android.lib.common.authentication; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient; | import com.owncloud.android.lib.common.OwnCloudClient; | ||||||
|  | import com.owncloud.android.lib.common.http.HttpClient; | ||||||
| import com.owncloud.android.lib.common.http.interceptors.BasicAuthInterceptor; | import com.owncloud.android.lib.common.http.interceptors.BasicAuthInterceptor; | ||||||
| import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor.RequestInterceptor; | import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor.RequestInterceptor; | ||||||
| 
 | 
 | ||||||
| @ -36,8 +37,6 @@ import org.apache.commons.httpclient.auth.BasicScheme; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| 
 | 
 | ||||||
| import okhttp3.Credentials; |  | ||||||
| 
 |  | ||||||
| public class OwnCloudBasicCredentials implements OwnCloudCredentials { | public class OwnCloudBasicCredentials implements OwnCloudCredentials { | ||||||
| 
 | 
 | ||||||
|     private static final String TAG = OwnCloudCredentials.class.getSimpleName(); |     private static final String TAG = OwnCloudCredentials.class.getSimpleName(); | ||||||
| @ -65,7 +64,7 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials { | |||||||
|         List<String> authPrefs = new ArrayList<>(1); |         List<String> authPrefs = new ArrayList<>(1); | ||||||
|         authPrefs.add(AuthPolicy.BASIC); |         authPrefs.add(AuthPolicy.BASIC); | ||||||
| 
 | 
 | ||||||
|         ArrayList<RequestInterceptor> requestInterceptors = client.getBaseOkHttpInterceptor().getRequestInterceptors(); |         ArrayList<RequestInterceptor> requestInterceptors = HttpClient.getOkHttpInterceptor().getRequestInterceptors(); | ||||||
| 
 | 
 | ||||||
|         // Clear previous basic credentials |         // Clear previous basic credentials | ||||||
|         for (RequestInterceptor requestInterceptor : requestInterceptors) { |         for (RequestInterceptor requestInterceptor : requestInterceptors) { | ||||||
| @ -74,9 +73,9 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         client.getBaseOkHttpInterceptor() |         HttpClient.getOkHttpInterceptor() | ||||||
|                 .addRequestInterceptor( |                 .addRequestInterceptor( | ||||||
|                         new BasicAuthInterceptor(Credentials.basic(mUsername, mPassword)) |                         new BasicAuthInterceptor(mUsername, mPassword) | ||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|         //TODO Update from here down |         //TODO Update from here down | ||||||
|  | |||||||
| @ -45,7 +45,9 @@ public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials { | |||||||
|         client.getParams().setAuthenticationPreemptive(false); |         client.getParams().setAuthenticationPreemptive(false); | ||||||
|         client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET); |         client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET); | ||||||
|         client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); |         client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); | ||||||
|         client.setFollowRedirects(false); | 
 | ||||||
|  |         // TODO | ||||||
|  | //        client.setFollowRedirects(false); | ||||||
| 
 | 
 | ||||||
|         Uri serverUri = client.getBaseUri(); |         Uri serverUri = client.getBaseUri(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -24,8 +24,6 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.common.http; | package com.owncloud.android.lib.common.http; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.utils.Log_OC; |  | ||||||
| 
 |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| 
 | 
 | ||||||
| @ -33,7 +31,6 @@ import okhttp3.Headers; | |||||||
| import okhttp3.OkHttpClient; | import okhttp3.OkHttpClient; | ||||||
| import okhttp3.Request; | import okhttp3.Request; | ||||||
| import okhttp3.Response; | import okhttp3.Response; | ||||||
| import okhttp3.internal.http2.Header; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Wrapper to perform http calls transparently by using: |  * Wrapper to perform http calls transparently by using: | ||||||
| @ -44,9 +41,14 @@ import okhttp3.internal.http2.Header; | |||||||
|  */ |  */ | ||||||
| public abstract class HttpBaseMethod { | public abstract class HttpBaseMethod { | ||||||
|     public abstract int execute() throws Exception; |     public abstract int execute() throws Exception; | ||||||
|  |     protected OkHttpClient mOkHttpClient; | ||||||
|     protected Request mRequest; |     protected Request mRequest; | ||||||
|     protected Response mResponse; |     protected Response mResponse; | ||||||
| 
 | 
 | ||||||
|  |     public HttpBaseMethod () { | ||||||
|  |         mOkHttpClient = HttpClient.getOkHttpClient(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     // Request |     // Request | ||||||
|     public Headers getRequestHeaders() { |     public Headers getRequestHeaders() { | ||||||
|         return mRequest.headers(); |         return mRequest.headers(); | ||||||
|  | |||||||
							
								
								
									
										67
									
								
								src/com/owncloud/android/lib/common/http/HttpClient.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/com/owncloud/android/lib/common/http/HttpClient.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,67 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 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; | ||||||
|  | 
 | ||||||
|  | import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; | ||||||
|  | import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor; | ||||||
|  | import com.owncloud.android.lib.common.http.interceptors.UserAgentInterceptor; | ||||||
|  | 
 | ||||||
|  | import java.util.Arrays; | ||||||
|  | 
 | ||||||
|  | import okhttp3.OkHttpClient; | ||||||
|  | import okhttp3.Protocol; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Client used to perform network operations | ||||||
|  |  * @author David González Verdugo | ||||||
|  |  */ | ||||||
|  | public class HttpClient { | ||||||
|  | 
 | ||||||
|  |     private static OkHttpClient mOkHttpClient; | ||||||
|  |     private static HttpInterceptor mOkHttpInterceptor; | ||||||
|  | 
 | ||||||
|  |     public static OkHttpClient getOkHttpClient() { | ||||||
|  |         if (mOkHttpClient == null) { | ||||||
|  | 
 | ||||||
|  |             mOkHttpInterceptor = new HttpInterceptor() | ||||||
|  |                     .addRequestInterceptor(new UserAgentInterceptor( | ||||||
|  |                                     // TODO Try to get rid of this dependency | ||||||
|  |                                     OwnCloudClientManagerFactory.getUserAgent() | ||||||
|  |                             ) | ||||||
|  |                     ); | ||||||
|  | 
 | ||||||
|  |             mOkHttpClient = new OkHttpClient.Builder() | ||||||
|  |                     .addInterceptor(mOkHttpInterceptor) | ||||||
|  |                     .protocols(Arrays.asList(Protocol.HTTP_1_1)) | ||||||
|  |                     .followRedirects(false) | ||||||
|  |                     .build(); | ||||||
|  |         } | ||||||
|  |         return mOkHttpClient; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static HttpInterceptor getOkHttpInterceptor() { | ||||||
|  |         return mOkHttpInterceptor; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										37
									
								
								src/com/owncloud/android/lib/common/http/HttpUtils.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/com/owncloud/android/lib/common/http/HttpUtils.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 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; | ||||||
|  | 
 | ||||||
|  | import okhttp3.HttpUrl; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * @author David González Verdugo | ||||||
|  |  */ | ||||||
|  | public class HttpUtils { | ||||||
|  | 
 | ||||||
|  |     public static HttpUrl stringUrlToHttpUrl(String url) { | ||||||
|  |         return HttpUrl.parse(url); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -24,6 +24,7 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.common.http.interceptors; | package com.owncloud.android.lib.common.http.interceptors; | ||||||
| 
 | 
 | ||||||
|  | import okhttp3.Credentials; | ||||||
| import okhttp3.Request; | import okhttp3.Request; | ||||||
| 
 | 
 | ||||||
| public class BasicAuthInterceptor implements HttpInterceptor.RequestInterceptor { | public class BasicAuthInterceptor implements HttpInterceptor.RequestInterceptor { | ||||||
| @ -31,8 +32,8 @@ public class BasicAuthInterceptor implements HttpInterceptor.RequestInterceptor | |||||||
|     private static final String AUTHORIZATION_HEADER = "Authorization"; |     private static final String AUTHORIZATION_HEADER = "Authorization"; | ||||||
|     private String mCredentials; |     private String mCredentials; | ||||||
| 
 | 
 | ||||||
|     public BasicAuthInterceptor(String credentials) { |     public BasicAuthInterceptor(String username, String password) { | ||||||
|         mCredentials = credentials; |         mCredentials = Credentials.basic(username, password); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -24,17 +24,14 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.common.http.methods.nonwebdav; | package com.owncloud.android.lib.common.http.methods.nonwebdav; | ||||||
| 
 | 
 | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| import okhttp3.Request; |  | ||||||
| 
 |  | ||||||
| /** | /** | ||||||
|  * OkHttp delete calls wrapper |  * OkHttp delete calls wrapper | ||||||
|  * @author David González Verdugo |  * @author David González Verdugo | ||||||
|  */ |  */ | ||||||
| public class DeleteMethod extends HttpMethod{ | public class DeleteMethod extends HttpMethod{ | ||||||
| 
 | 
 | ||||||
|     public DeleteMethod(OkHttpClient okHttpClient, String httpUrl) { |     public DeleteMethod(String httpUrl) { | ||||||
|         super(okHttpClient, httpUrl); |         super(httpUrl); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -27,7 +27,6 @@ package com.owncloud.android.lib.common.http.methods.nonwebdav; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| 
 | 
 | ||||||
| import okhttp3.HttpUrl; | import okhttp3.HttpUrl; | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * OkHttp get calls wrapper |  * OkHttp get calls wrapper | ||||||
| @ -35,12 +34,12 @@ import okhttp3.OkHttpClient; | |||||||
|  */ |  */ | ||||||
| public class GetMethod extends HttpMethod { | public class GetMethod extends HttpMethod { | ||||||
| 
 | 
 | ||||||
|     public GetMethod(OkHttpClient okHttpClient, String httpUrl) { |     public GetMethod(String httpUrl) { | ||||||
|         super(okHttpClient, httpUrl); |         super(httpUrl); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public GetMethod(OkHttpClient okHttpClient, HttpUrl httpUrl) { |     public GetMethod(HttpUrl httpUrl) { | ||||||
|         super(okHttpClient, httpUrl); |         super(httpUrl); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -29,7 +29,6 @@ import com.owncloud.android.lib.common.http.HttpBaseMethod; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| 
 | 
 | ||||||
| import okhttp3.HttpUrl; | import okhttp3.HttpUrl; | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| import okhttp3.Request; | import okhttp3.Request; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -38,17 +37,16 @@ import okhttp3.Request; | |||||||
|  * @author David González Verdugo |  * @author David González Verdugo | ||||||
|  */ |  */ | ||||||
| public abstract class HttpMethod extends HttpBaseMethod { | public abstract class HttpMethod extends HttpBaseMethod { | ||||||
|     protected OkHttpClient mOkHttpClient; |  | ||||||
| 
 | 
 | ||||||
|     public HttpMethod(OkHttpClient okHttpClient, String httpUrl) { |     public HttpMethod(String httpUrl) { | ||||||
|         mOkHttpClient = okHttpClient; |         super(); | ||||||
|         mRequest = new Request.Builder() |         mRequest = new Request.Builder() | ||||||
|                 .url(httpUrl) |                 .url(httpUrl) | ||||||
|                 .build(); |                 .build(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public HttpMethod(OkHttpClient okHttpClient, HttpUrl httpUrl) { |     public HttpMethod(HttpUrl httpUrl) { | ||||||
|         mOkHttpClient = okHttpClient; |         super(); | ||||||
|         mRequest = new Request.Builder() |         mRequest = new Request.Builder() | ||||||
|                 .url(httpUrl) |                 .url(httpUrl) | ||||||
|                 .build(); |                 .build(); | ||||||
|  | |||||||
| @ -24,8 +24,6 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.common.http.methods.nonwebdav; | package com.owncloud.android.lib.common.http.methods.nonwebdav; | ||||||
| 
 | 
 | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| import okhttp3.Request; |  | ||||||
| import okhttp3.RequestBody; | import okhttp3.RequestBody; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -36,8 +34,8 @@ public class PostMethod extends HttpMethod { | |||||||
| 
 | 
 | ||||||
|     private RequestBody mRequestBody; |     private RequestBody mRequestBody; | ||||||
| 
 | 
 | ||||||
|     public PostMethod(OkHttpClient okHttpClient, String httpUrl, RequestBody requestBody){ |     public PostMethod(String httpUrl, RequestBody requestBody){ | ||||||
|         super(okHttpClient, httpUrl); |         super(httpUrl); | ||||||
|         mRequestBody = requestBody; |         mRequestBody = requestBody; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -24,16 +24,14 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.common.http.methods.nonwebdav; | package com.owncloud.android.lib.common.http.methods.nonwebdav; | ||||||
| 
 | 
 | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| import okhttp3.Request; |  | ||||||
| import okhttp3.RequestBody; | import okhttp3.RequestBody; | ||||||
| 
 | 
 | ||||||
| public class PutMethod extends HttpMethod{ | public class PutMethod extends HttpMethod{ | ||||||
| 
 | 
 | ||||||
|     private RequestBody mRequestBody; |     private RequestBody mRequestBody; | ||||||
| 
 | 
 | ||||||
|     public PutMethod(OkHttpClient okHttpClient, String httpUrl, RequestBody requestBody){ |     public PutMethod(String httpUrl, RequestBody requestBody){ | ||||||
|         super(okHttpClient, httpUrl); |         super(httpUrl); | ||||||
|         mRequestBody = requestBody; |         mRequestBody = requestBody; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -29,7 +29,6 @@ import com.owncloud.android.lib.common.http.HttpBaseMethod; | |||||||
| import at.bitfire.dav4android.DavOCResource; | import at.bitfire.dav4android.DavOCResource; | ||||||
| import at.bitfire.dav4android.DavResource; | import at.bitfire.dav4android.DavResource; | ||||||
| import okhttp3.HttpUrl; | import okhttp3.HttpUrl; | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Wrapper to perform WebDAV (dav4android) calls |  * Wrapper to perform WebDAV (dav4android) calls | ||||||
| @ -39,8 +38,12 @@ public abstract class DavMethod extends HttpBaseMethod { | |||||||
| 
 | 
 | ||||||
|     protected DavResource mDavResource; |     protected DavResource mDavResource; | ||||||
| 
 | 
 | ||||||
|     public DavMethod(OkHttpClient okHttpClient, HttpUrl httpUrl) { |     public DavMethod(HttpUrl httpUrl) { | ||||||
|         mDavResource = new DavOCResource(okHttpClient, httpUrl); |         super(); | ||||||
|  |         mDavResource = new DavOCResource( | ||||||
|  |                 mOkHttpClient, | ||||||
|  |                 httpUrl | ||||||
|  |         ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public DavResource getDavResource() { |     public DavResource getDavResource() { | ||||||
|  | |||||||
| @ -33,7 +33,6 @@ import at.bitfire.dav4android.exception.DavException; | |||||||
| import at.bitfire.dav4android.exception.HttpException; | import at.bitfire.dav4android.exception.HttpException; | ||||||
| import at.bitfire.dav4android.exception.UnauthorizedException; | import at.bitfire.dav4android.exception.UnauthorizedException; | ||||||
| import okhttp3.HttpUrl; | import okhttp3.HttpUrl; | ||||||
| import okhttp3.OkHttpClient; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Propfind calls wrapper |  * Propfind calls wrapper | ||||||
| @ -44,8 +43,8 @@ public class PropfindMethod extends DavMethod { | |||||||
|     private int mDepth; |     private int mDepth; | ||||||
|     private Set<DavResource> mMembers; |     private Set<DavResource> mMembers; | ||||||
| 
 | 
 | ||||||
|     public PropfindMethod(OkHttpClient okHttpClient, HttpUrl httpUrl, int depth) { |     public PropfindMethod(HttpUrl httpUrl, int depth) { | ||||||
|         super(okHttpClient, httpUrl); |         super(httpUrl); | ||||||
|         mDepth = depth; |         mDepth = depth; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -26,6 +26,7 @@ package com.owncloud.android.lib.resources.files; | |||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient; | import com.owncloud.android.lib.common.OwnCloudClient; | ||||||
| import com.owncloud.android.lib.common.http.HttpConstants; | import com.owncloud.android.lib.common.http.HttpConstants; | ||||||
|  | import com.owncloud.android.lib.common.http.HttpUtils; | ||||||
| import com.owncloud.android.lib.common.http.methods.webdav.PropfindMethod; | import com.owncloud.android.lib.common.http.methods.webdav.PropfindMethod; | ||||||
| import com.owncloud.android.lib.common.network.RedirectionPath; | import com.owncloud.android.lib.common.network.RedirectionPath; | ||||||
| import com.owncloud.android.lib.common.network.WebdavUtils; | import com.owncloud.android.lib.common.network.WebdavUtils; | ||||||
| @ -81,8 +82,7 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { | |||||||
| 
 | 
 | ||||||
| //            client.setFollowRedirects(false); | //            client.setFollowRedirects(false); | ||||||
|             PropfindMethod propfindMethod = new PropfindMethod( |             PropfindMethod propfindMethod = new PropfindMethod( | ||||||
|                     client.getOkHttpClient(), |                     HttpUtils.stringUrlToHttpUrl(client.getNewWebDavUri() + WebdavUtils.encodePath(mPath)), | ||||||
|                     HttpUrl.parse(client.getNewWebDavUri() + WebdavUtils.encodePath(mPath)), |  | ||||||
|                     0); |                     0); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(propfindMethod); |             int status = client.executeHttpMethod(propfindMethod); | ||||||
|  | |||||||
| @ -74,7 +74,6 @@ public class ReadRemoteFolderOperation extends RemoteOperation { | |||||||
|         try { |         try { | ||||||
| 
 | 
 | ||||||
|             PropfindMethod propfindMethod = new PropfindMethod( |             PropfindMethod propfindMethod = new PropfindMethod( | ||||||
|                     client.getOkHttpClient(), |  | ||||||
|                     HttpUrl.parse(client.getNewWebDavUri() + WebdavUtils.encodePath(mRemotePath)), |                     HttpUrl.parse(client.getNewWebDavUri() + WebdavUtils.encodePath(mRemotePath)), | ||||||
|                     1); |                     1); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -231,8 +231,7 @@ public class CreateRemoteShareOperation extends RemoteOperation { | |||||||
|             Uri.Builder uriBuilder = requestUri.buildUpon(); |             Uri.Builder uriBuilder = requestUri.buildUpon(); | ||||||
|             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); |             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); | ||||||
| 
 | 
 | ||||||
|             PostMethod postMethod = new PostMethod(client.getOkHttpClient(), |             PostMethod postMethod = new PostMethod(uriBuilder.build().toString(), formBody); | ||||||
|                     uriBuilder.build().toString(), formBody); |  | ||||||
|             postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); |             postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); | ||||||
|             postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -63,8 +63,8 @@ public class GetRemoteShareOperation extends RemoteOperation { | |||||||
|             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); |             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); | ||||||
|             uriBuilder.appendEncodedPath(Long.toString(mRemoteId)); |             uriBuilder.appendEncodedPath(Long.toString(mRemoteId)); | ||||||
| 
 | 
 | ||||||
|             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), |             GetMethod getMethod = new GetMethod(uriBuilder.build().toString()); | ||||||
|                     uriBuilder.build().toString()); | 
 | ||||||
|             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -130,7 +130,7 @@ public class GetRemoteShareesOperation extends RemoteOperation{ | |||||||
|             uriBuilder.appendQueryParameter(PARAM_PAGE, String.valueOf(mPage)); |             uriBuilder.appendQueryParameter(PARAM_PAGE, String.valueOf(mPage)); | ||||||
|             uriBuilder.appendQueryParameter(PARAM_PER_PAGE, String.valueOf(mPerPage)); |             uriBuilder.appendQueryParameter(PARAM_PER_PAGE, String.valueOf(mPerPage)); | ||||||
| 
 | 
 | ||||||
|             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), uriBuilder.build().toString()); |             GetMethod getMethod = new GetMethod(uriBuilder.build().toString()); | ||||||
|             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
|  | |||||||
| @ -93,7 +93,7 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation { | |||||||
|             httpBuilder.addQueryParameter(PARAM_RESHARES, String.valueOf(mReshares)); |             httpBuilder.addQueryParameter(PARAM_RESHARES, String.valueOf(mReshares)); | ||||||
|             httpBuilder.addQueryParameter(PARAM_SUBFILES, String.valueOf(mSubfiles)); |             httpBuilder.addQueryParameter(PARAM_SUBFILES, String.valueOf(mSubfiles)); | ||||||
| 
 | 
 | ||||||
|             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), httpBuilder.build()); |             GetMethod getMethod = new GetMethod(httpBuilder.build()); | ||||||
|             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
|  | |||||||
| @ -57,8 +57,7 @@ public class GetRemoteSharesOperation extends RemoteOperation { | |||||||
|             Uri.Builder uriBuilder = requestUri.buildUpon(); |             Uri.Builder uriBuilder = requestUri.buildUpon(); | ||||||
|             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); |             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); | ||||||
| 
 | 
 | ||||||
|             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), |             GetMethod getMethod = new GetMethod(uriBuilder.build().toString()); | ||||||
|                     uriBuilder.build().toString()); |  | ||||||
|             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
| @ -75,7 +74,6 @@ public class GetRemoteSharesOperation extends RemoteOperation { | |||||||
|             } else { |             } else { | ||||||
|                 result = new RemoteOperationResult(getMethod); |                 result = new RemoteOperationResult(getMethod); | ||||||
|             } |             } | ||||||
| 
 |  | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             result = new RemoteOperationResult(e); |             result = new RemoteOperationResult(e); | ||||||
|             Log_OC.e(TAG, "Exception while getting remote shares ", e); |             Log_OC.e(TAG, "Exception while getting remote shares ", e); | ||||||
|  | |||||||
| @ -72,8 +72,8 @@ public class RemoveRemoteShareOperation extends RemoteOperation { | |||||||
|             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); |             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); | ||||||
|             uriBuilder.appendEncodedPath(String.valueOf(mRemoteShareId)); |             uriBuilder.appendEncodedPath(String.valueOf(mRemoteShareId)); | ||||||
| 
 | 
 | ||||||
|             DeleteMethod deleteMethod = new DeleteMethod(client.getOkHttpClient(), |             DeleteMethod deleteMethod = new DeleteMethod(uriBuilder.build().toString()); | ||||||
|                     uriBuilder.build().toString()); | 
 | ||||||
|             deleteMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             deleteMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(deleteMethod); |             int status = client.executeHttpMethod(deleteMethod); | ||||||
|  | |||||||
| @ -40,8 +40,6 @@ import java.util.Calendar; | |||||||
| import java.util.Locale; | import java.util.Locale; | ||||||
| 
 | 
 | ||||||
| import okhttp3.FormBody; | import okhttp3.FormBody; | ||||||
| import okhttp3.Request; |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Updates parameters of an existing Share resource, known its remote ID. |  * Updates parameters of an existing Share resource, known its remote ID. | ||||||
| @ -199,17 +197,15 @@ public class UpdateRemoteShareOperation extends RemoteOperation { | |||||||
|                 formBodyBuilder.add(PARAM_PERMISSIONS, Integer.toString(mPermissions)); |                 formBodyBuilder.add(PARAM_PERMISSIONS, Integer.toString(mPermissions)); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             FormBody formBody = formBodyBuilder.build(); | ||||||
|  | 
 | ||||||
|             Uri requestUri = client.getBaseUri(); |             Uri requestUri = client.getBaseUri(); | ||||||
|             Uri.Builder uriBuilder = requestUri.buildUpon(); |             Uri.Builder uriBuilder = requestUri.buildUpon(); | ||||||
|             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH.substring(1)); |             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH.substring(1)); | ||||||
|             uriBuilder.appendEncodedPath(Long.toString(mRemoteId)); |             uriBuilder.appendEncodedPath(Long.toString(mRemoteId)); | ||||||
| 
 | 
 | ||||||
|             FormBody formBody = formBodyBuilder.build(); |             PutMethod putMethod = new PutMethod(uriBuilder.build().toString(), formBody); | ||||||
| 
 |             putMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); | ||||||
|             PutMethod putMethod = new PutMethod(client.getOkHttpClient(), |  | ||||||
|                     uriBuilder.build().toString(), formBody); |  | ||||||
|             putMethod.setRequestHeader("Content-Type", |  | ||||||
|                     "application/x-www-form-urlencoded; charset=utf-8"); |  | ||||||
|             putMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             putMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(putMethod); |             int status = client.executeHttpMethod(putMethod); | ||||||
|  | |||||||
| @ -130,7 +130,7 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation { | |||||||
| 
 | 
 | ||||||
|             String url = uriBuilder.build().toString(); |             String url = uriBuilder.build().toString(); | ||||||
| 
 | 
 | ||||||
|             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), url); |             GetMethod getMethod = new GetMethod(url); | ||||||
|             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |             getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
|  | |||||||
| @ -29,6 +29,7 @@ import android.net.ConnectivityManager; | |||||||
| import android.net.Uri; | import android.net.Uri; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient; | import com.owncloud.android.lib.common.OwnCloudClient; | ||||||
|  | import com.owncloud.android.lib.common.http.HttpClient; | ||||||
| import com.owncloud.android.lib.common.http.HttpConstants; | import com.owncloud.android.lib.common.http.HttpConstants; | ||||||
| import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod; | import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod; | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperation; | import com.owncloud.android.lib.common.operations.RemoteOperation; | ||||||
| @ -78,8 +79,11 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|         try { |         try { | ||||||
|             String url = baseUrlSt + OwnCloudClient.STATUS_PATH; |             String url = baseUrlSt + OwnCloudClient.STATUS_PATH; | ||||||
| 
 | 
 | ||||||
|             client.setFollowRedirects(false); |             HttpClient.getOkHttpClient() | ||||||
|             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), url); |                     .newBuilder() | ||||||
|  |                     .followRedirects(false); | ||||||
|  | 
 | ||||||
|  |             GetMethod getMethod = new GetMethod(url); | ||||||
| 
 | 
 | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -86,7 +86,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation { | |||||||
|             ; |             ; | ||||||
|             Log_OC.d(TAG, "avatar URI: " + url); |             Log_OC.d(TAG, "avatar URI: " + url); | ||||||
| 
 | 
 | ||||||
|             getMethod = new GetMethod(client.getOkHttpClient(), url); |             getMethod = new GetMethod(url); | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
| 
 | 
 | ||||||
|             if (isSuccess(status)) { |             if (isSuccess(status)) { | ||||||
|  | |||||||
| @ -76,7 +76,7 @@ public class GetRemoteUserInfoOperation extends RemoteOperation { | |||||||
| 
 | 
 | ||||||
|             String url = client.getBaseUri() + OCS_ROUTE; |             String url = client.getBaseUri() + OCS_ROUTE; | ||||||
| 
 | 
 | ||||||
|             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), url); |             GetMethod getMethod = new GetMethod(url); | ||||||
|             int status = client.executeHttpMethod(getMethod); |             int status = client.executeHttpMethod(getMethod); | ||||||
| 
 | 
 | ||||||
|             if (isSuccess(status)) { |             if (isSuccess(status)) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user