Re add the remove CurlLoggingInterceptor

This commit is contained in:
Benoit Marty 2019-09-16 14:43:08 +02:00
parent 6bda437f5d
commit ca6bcde82d
1 changed files with 8 additions and 13 deletions

View File

@ -44,7 +44,6 @@ import im.vector.matrix.android.internal.session.room.tombstone.RoomTombstoneEve
import im.vector.matrix.android.internal.util.md5 import im.vector.matrix.android.internal.util.md5
import io.realm.RealmConfiguration import io.realm.RealmConfiguration
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit import retrofit2.Retrofit
import java.io.File import java.io.File
@ -94,29 +93,25 @@ internal abstract class SessionModule {
.build() .build()
} }
// TODO Check with Ganfra, I do not want to add this, I want to use the CurlLoggingInterceptor of @MatrixScope
@Provides
@JvmStatic
fun providesCurlLoggingInterceptor(): CurlLoggingInterceptor {
return CurlLoggingInterceptor(HttpLoggingInterceptor.Logger.DEFAULT)
}
@JvmStatic @JvmStatic
@Provides @Provides
@SessionScope @SessionScope
@Authenticated @Authenticated
fun providesOkHttpClient(@Unauthenticated okHttpClient: OkHttpClient, fun providesOkHttpClient(@Unauthenticated okHttpClient: OkHttpClient,
accessTokenInterceptor: AccessTokenInterceptor, accessTokenInterceptor: AccessTokenInterceptor): OkHttpClient {
curlLoggingInterceptor: CurlLoggingInterceptor): OkHttpClient {
return okHttpClient.newBuilder() return okHttpClient.newBuilder()
.apply { .apply {
// Remove the previous CurlLoggingInterceptor, to add it after the accessTokenInterceptor // Remove the previous CurlLoggingInterceptor, to add it after the accessTokenInterceptor
val existingCurlInterceptors = interceptors().filterIsInstance<CurlLoggingInterceptor>() val existingCurlInterceptors = interceptors().filterIsInstance<CurlLoggingInterceptor>()
interceptors().removeAll(existingCurlInterceptors) interceptors().removeAll(existingCurlInterceptors)
addInterceptor(accessTokenInterceptor)
// Re add eventually the curl logging interceptors
existingCurlInterceptors.forEach {
addInterceptor(it)
}
} }
.addInterceptor(accessTokenInterceptor)
.addInterceptor(curlLoggingInterceptor)
.build() .build()
} }