Search in sources :

Example 81 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project open-event-orga-app by fossasia.

the class NetworkModule method loggingInterceptor.

@Provides
@Singleton
HttpLoggingInterceptor loggingInterceptor() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    return interceptor;
}
Also used : HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 82 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project dhis2-android-sdk by dhis2.

the class D2Factory method create.

public static D2 create(String url, DatabaseAdapter databaseAdapter) {
    ConfigurationModel config = ConfigurationModel.builder().serverUrl(HttpUrl.parse(url)).build();
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    return new D2.Builder().configuration(config).databaseAdapter(databaseAdapter).okHttpClient(new OkHttpClient.Builder().addInterceptor(BasicAuthenticatorFactory.create(databaseAdapter)).addInterceptor(loggingInterceptor).build()).build();
}
Also used : ConfigurationModel(org.hisp.dhis.android.core.configuration.ConfigurationModel) OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor)

Example 83 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project apps-android-wikipedia by wikimedia.

the class OkHttpConnectionFactory method createClient.

@NonNull
private static OkHttpClient createClient() {
    SharedPreferenceCookieManager cookieManager = SharedPreferenceCookieManager.getInstance();
    // TODO: consider using okhttp3.CookieJar implementation instead of JavaNetCookieJar wrapper
    CookieJar cookieJar = new JavaNetCookieJar(cookieManager);
    return new OkHttpClient.Builder().cookieJar(cookieJar).cache(NET_CACHE).addInterceptor(new HttpLoggingInterceptor().setLevel(Prefs.getRetrofitLogLevel())).addInterceptor(new UnsuccessfulResponseInterceptor()).addInterceptor(new StatusResponseInterceptor(RbSwitch.INSTANCE)).addNetworkInterceptor(new StripMustRevalidateResponseInterceptor()).addInterceptor(new CommonHeaderRequestInterceptor()).addInterceptor(new DefaultMaxStaleRequestInterceptor()).addInterceptor(new CacheControlRequestInterceptor()).addInterceptor(new OfflineCacheInterceptor(SAVE_CACHE)).addInterceptor(new WikipediaZeroResponseInterceptor(WikipediaApp.getInstance().getWikipediaZeroHandler())).addInterceptor(new TestStubInterceptor()).build();
}
Also used : JavaNetCookieJar(okhttp3.JavaNetCookieJar) OkHttpClient(okhttp3.OkHttpClient) SharedPreferenceCookieManager(org.wikipedia.dataclient.SharedPreferenceCookieManager) JavaNetCookieJar(okhttp3.JavaNetCookieJar) CookieJar(okhttp3.CookieJar) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) NonNull(android.support.annotation.NonNull)

Example 84 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project Varis-Android by dkhmelenko.

the class NetworkModule method okHttpClient.

@Provides
@Singleton
public static OkHttpClient okHttpClient() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    return new OkHttpClient.Builder().addInterceptor(interceptor).followRedirects(false).followSslRedirects(false).build();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 85 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project zype-android by zype.

the class ZypeApi method getInstance.

public static synchronized ZypeApi getInstance() {
    if (instance == null) {
        instance = new ZypeApi();
        // Needs to log retrofit calls
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
        Gson gson = new GsonBuilder().setLenient().create();
        retrofit = new Retrofit.Builder().baseUrl(BASE_URL).client(client).addConverterFactory(GsonConverterFactory.create(gson)).build();
        apiImpl = retrofit.create(IZypeApi.class);
    }
    return instance;
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor)

Aggregations

HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)107 OkHttpClient (okhttp3.OkHttpClient)87 Provides (dagger.Provides)27 Retrofit (retrofit2.Retrofit)25 GsonBuilder (com.google.gson.GsonBuilder)24 Singleton (javax.inject.Singleton)24 Cache (okhttp3.Cache)19 Request (okhttp3.Request)16 File (java.io.File)15 Response (okhttp3.Response)15 IOException (java.io.IOException)14 Gson (com.google.gson.Gson)13 Interceptor (okhttp3.Interceptor)11 StethoInterceptor (com.facebook.stetho.okhttp3.StethoInterceptor)6 LoggingInterceptor (com.toshi.manager.network.interceptor.LoggingInterceptor)6 List (java.util.List)5 ErrorInterceptor (me.postaddict.instagram.scraper.interceptor.ErrorInterceptor)5 FakeBrowserInterceptor (me.postaddict.instagram.scraper.interceptor.FakeBrowserInterceptor)5 ResponseBody (okhttp3.ResponseBody)5 BeforeClass (org.junit.BeforeClass)5