mirror of
https://github.com/owncloud/android-library.git
synced 2026-08-11 16:33:03 +00:00
add debug interceptor
This commit is contained in:
committed by
Abel García de Prada
parent
a7e9138593
commit
7e507abf32
+9
@@ -0,0 +1,9 @@
|
||||
package com.owncloud.android.lib.common.http
|
||||
|
||||
import com.facebook.stetho.okhttp3.StethoInterceptor
|
||||
|
||||
class DebugInterceptorFactory {
|
||||
companion object {
|
||||
fun getInterceptor() = StethoInterceptor()
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.owncloud.android.lib.common.http
|
||||
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
|
||||
class DummyInterceptor : Interceptor {
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
return chain.proceed(chain.request())
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ public class HttpClient {
|
||||
private static Context sContext;
|
||||
private static HashMap<String, List<Cookie>> sCookieStore = new HashMap<>();
|
||||
private static LogInterceptor sLogInterceptor;
|
||||
private static DebugInterceptor sDebugInterceptor;
|
||||
|
||||
public static OkHttpClient getOkHttpClient() {
|
||||
if (sOkHttpClient == null) {
|
||||
@@ -111,6 +112,7 @@ public class HttpClient {
|
||||
CookieJar cookieJar) {
|
||||
return new OkHttpClient.Builder()
|
||||
.addNetworkInterceptor(getLogInterceptor())
|
||||
.addNetworkInterceptor(DebugInterceptorFactory.Companion.getInterceptor())
|
||||
.protocols(Collections.singletonList(Protocol.HTTP_1_1))
|
||||
.readTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
@@ -129,6 +131,13 @@ public class HttpClient {
|
||||
return sLogInterceptor;
|
||||
}
|
||||
|
||||
public static DebugInterceptor getDebugInterceptor() {
|
||||
if (sDebugInterceptor == null) {
|
||||
sDebugInterceptor = new DebugInterceptor();
|
||||
}
|
||||
return sDebugInterceptor;
|
||||
}
|
||||
|
||||
public static List<Cookie> getCookiesFromUrl(HttpUrl httpUrl) {
|
||||
return sCookieStore.get(httpUrl.host());
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.owncloud.android.lib.common.http
|
||||
|
||||
class DebugInterceptorFactory {
|
||||
companion object {
|
||||
fun getInterceptor() = DummyInterceptor()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user