mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Basic logging with redacted sensitive headers (#3159)
This commit is contained in:
parent
2e0281eaee
commit
13d847ea77
2 changed files with 12 additions and 1 deletions
|
|
@ -53,6 +53,7 @@ dependencies {
|
|||
api('com.github.tony19:logback-android-classic:1.1.1-6') {
|
||||
exclude group: 'com.google.android', module: 'android'
|
||||
}
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:4.2.0"
|
||||
|
||||
// Dependency injector
|
||||
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
|
||||
|
|
|
|||
|
|
@ -31,12 +31,22 @@ public final class OkHttpConnectionFactory {
|
|||
return new OkHttpClient.Builder()
|
||||
.cookieJar(SharedPreferenceCookieManager.getInstance())
|
||||
.cache(NET_CACHE)
|
||||
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
|
||||
.addInterceptor(getLoggingInterceptor())
|
||||
.addInterceptor(new UnsuccessfulResponseInterceptor())
|
||||
.addInterceptor(new CommonHeaderRequestInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static HttpLoggingInterceptor getLoggingInterceptor() {
|
||||
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor()
|
||||
.setLevel(HttpLoggingInterceptor.Level.BASIC);
|
||||
|
||||
httpLoggingInterceptor.redactHeader("Authorization");
|
||||
httpLoggingInterceptor.redactHeader("Cookie");
|
||||
|
||||
return httpLoggingInterceptor;
|
||||
}
|
||||
|
||||
private static class CommonHeaderRequestInterceptor implements Interceptor {
|
||||
@Override @NonNull public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
Request request = chain.request().newBuilder()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue