Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 61508c8

Browse files
authored
Merge pull request #469 from owncloud/feature/add_stetho
Feature/add stetho
2 parents a7e9138 + 5619c1d commit 61508c8

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed

owncloudComLibrary/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies {
1616

1717
testImplementation 'junit:junit:4.13.2'
1818
testImplementation 'org.robolectric:robolectric:4.7.3'
19+
debugImplementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
1920
}
2021

2122
android {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* ownCloud Android Library is available under MIT license
2+
* Copyright (C) 2020 ownCloud GmbH.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
24+
package com.owncloud.android.lib.common.http
25+
26+
import com.facebook.stetho.okhttp3.StethoInterceptor
27+
28+
object DebugInterceptorFactory {
29+
fun getInterceptor() = StethoInterceptor()
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* ownCloud Android Library is available under MIT license
2+
* Copyright (C) 2020 ownCloud GmbH.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*
23+
*/
24+
25+
package com.owncloud.android.lib.common.http
26+
27+
import okhttp3.Interceptor
28+
29+
class DummyInterceptor : Interceptor {
30+
override fun intercept(chain: Interceptor.Chain) = chain.proceed(chain.request())
31+
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import okhttp3.Cookie;
3232
import okhttp3.CookieJar;
3333
import okhttp3.HttpUrl;
34+
import okhttp3.Interceptor;
3435
import okhttp3.OkHttpClient;
3536
import okhttp3.Protocol;
3637
import okhttp3.TlsVersion;
@@ -58,6 +59,7 @@ public class HttpClient {
5859
private static Context sContext;
5960
private static HashMap<String, List<Cookie>> sCookieStore = new HashMap<>();
6061
private static LogInterceptor sLogInterceptor;
62+
private static Interceptor sDebugInterceptor;
6163

6264
public static OkHttpClient getOkHttpClient() {
6365
if (sOkHttpClient == null) {
@@ -111,6 +113,7 @@ private static OkHttpClient buildNewOkHttpClient(SSLSocketFactory sslSocketFacto
111113
CookieJar cookieJar) {
112114
return new OkHttpClient.Builder()
113115
.addNetworkInterceptor(getLogInterceptor())
116+
.addNetworkInterceptor(DebugInterceptorFactory.INSTANCE.getInterceptor())
114117
.protocols(Collections.singletonList(Protocol.HTTP_1_1))
115118
.readTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
116119
.writeTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* ownCloud Android Library is available under MIT license
2+
* Copyright (C) 2020 ownCloud GmbH.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*
23+
*/
24+
25+
package com.owncloud.android.lib.common.http
26+
27+
object DebugInterceptorFactory {
28+
fun getInterceptor() = DummyInterceptor()
29+
}

0 commit comments

Comments
 (0)