use of okhttp3.logging.HttpLoggingInterceptor in project autorest.java by Azure.
the class CustomBaseUriMoreOptionsTests method setup.
@BeforeClass
public static void setup() {
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY));
client = new AutoRestParameterizedCustomHostTestClientImpl(clientBuilder, new Retrofit.Builder());
client.withSubscriptionId("test12");
}
use of okhttp3.logging.HttpLoggingInterceptor in project kripton by xcesco.
the class NetworkClient method instance.
public static OkHttpClient instance() {
if (client == null) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
/* ConnectionSpec spec = new
ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2)
.cipherSuites(
CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
.build();*/
client = (new OkHttpClient.Builder()).readTimeout(60, TimeUnit.SECONDS).connectTimeout(60, TimeUnit.SECONDS).addInterceptor(logging).build();
}
return client;
}
use of okhttp3.logging.HttpLoggingInterceptor in project open-event-android by fossasia.
the class APIClient method getOpenEventAPI.
public static OpenEventAPI getOpenEventAPI() {
if (openEventAPI == null) {
OkHttpClient okHttpClient = okHttpClientBuilder.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC)).authenticator(AuthUtil.getAuthenticator()).build();
ObjectMapper objectMapper = getObjectMapper();
Class[] classes = { Event.class, Track.class, Speaker.class, Sponsor.class, Session.class, Microlocation.class, User.class, FAQ.class, Notification.class, DiscountCode.class };
openEventAPI = new Retrofit.Builder().client(okHttpClient).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).addConverterFactory(new JSONAPIConverterFactory(objectMapper, classes)).addConverterFactory(JacksonConverterFactory.create(getObjectMapper())).baseUrl(Urls.BASE_URL).build().create(OpenEventAPI.class);
}
return openEventAPI;
}
use of okhttp3.logging.HttpLoggingInterceptor in project anitrend-app by AniTrend.
the class WebFactory method createCrunchyService.
public static EpisodeModel createCrunchyService(boolean feeds, Context context) {
if (mCrunchy == null) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder().readTimeout(45, TimeUnit.SECONDS).connectTimeout(45, TimeUnit.SECONDS).addInterceptor(new CacheInterceptor(context, true)).addNetworkInterceptor(new NetworkCacheInterceptor(context, true)).cache(CompatUtil.cacheProvider(context));
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC);
httpClient.addInterceptor(httpLoggingInterceptor);
}
crunchyBuilder.client(httpClient.build());
}
mCrunchy = crunchyBuilder.baseUrl(feeds ? BuildConfig.FEEDS_LINK : BuildConfig.CRUNCHY_LINK).build();
return mCrunchy.create(EpisodeModel.class);
}
use of okhttp3.logging.HttpLoggingInterceptor in project anitrend-app by AniTrend.
the class WebFactory method createService.
/**
* Generates retrofit service classes in a background thread
* and handles creation of API tokens or renewal of them
* <br/>
*
* @param serviceClass The interface class to use such as
*
* @param context A valid application, fragment or activity context but must be application context
*/
public static <S> S createService(@NonNull Class<S> serviceClass, Context context) {
WebTokenRequest.getToken(context);
if (mRetrofit == null) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder().readTimeout(35, TimeUnit.SECONDS).connectTimeout(35, TimeUnit.SECONDS).addInterceptor(new AuthInterceptor(context));
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(httpLoggingInterceptor);
}
mRetrofit = anitrendBuilder.client(httpClient.build()).addConverterFactory(GraphConverter.create(context)).build();
}
return mRetrofit.create(serviceClass);
}
Aggregations