Skip to content

Instantly share code, notes, and snippets.

@dinorahtovar
Created July 19, 2018 17:15
Show Gist options
  • Save dinorahtovar/3144797913484286a6c530e947cb9383 to your computer and use it in GitHub Desktop.
Save dinorahtovar/3144797913484286a6c530e947cb9383 to your computer and use it in GitHub Desktop.
@Provides
@Singleton
fun getUnsafeOkHttpClient(): OkHttpClient {
val interceptor = HttpLoggingInterceptor()
interceptor.level = HttpLoggingInterceptor.Level.BODY
val builder = OkHttpClient.Builder()
builder.addInterceptor(interceptor)
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.followRedirects(true)
.followSslRedirects(true)
.addInterceptor { chain ->
val newRequest = chain.request().newBuilder()
.addHeader("Authorization", UUID.randomUUID().toString())
.build()
chain.proceed(newRequest)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment