use of okhttp3.logging.HttpLoggingInterceptor in project FastHub by k0shk0sh.
the class LoginProvider method provideOkHttpClient.
private static OkHttpClient provideOkHttpClient(@Nullable String authToken, @Nullable String otp) {
OkHttpClient.Builder client = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
client.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY));
}
client.addInterceptor(new AuthenticationInterceptor(authToken, otp));
return client.build();
}
use of okhttp3.logging.HttpLoggingInterceptor in project FastHub by k0shk0sh.
the class RestProvider method provideOkHttpClient.
public static OkHttpClient provideOkHttpClient() {
if (okHttpClient == null) {
OkHttpClient.Builder client = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
client.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY));
}
client.addInterceptor(new AuthenticationInterceptor());
client.addInterceptor(new PaginationInterceptor());
client.addInterceptor(new ContentTypeInterceptor());
okHttpClient = client.build();
}
return okHttpClient;
}
use of okhttp3.logging.HttpLoggingInterceptor in project okhttp-digest by rburgst.
the class BasicAuthenticatorWithMockWebserverTest method setUp.
@Before
public void setUp() throws Exception {
credentials = new Credentials("user1", "user1");
sut = new BasicAuthenticator(credentials);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
final Map<String, CachingAuthenticator> authCache = new ConcurrentHashMap<>();
HttpLoggingInterceptor logger = new HttpLoggingInterceptor(new StdOutLogger());
logger.setLevel(HttpLoggingInterceptor.Level.HEADERS);
spy = spy(sut);
client = builder.authenticator(new CachingAuthenticatorDecorator(spy, authCache)).addInterceptor(new AuthenticationCacheInterceptor(authCache)).addNetworkInterceptor(logger).build();
unauthorizedResponse = new MockResponse().setResponseCode(401).addHeader("WWW-Authenticate", "Basic realm=\"myrealm\"");
successResponse = new MockResponse().setBody("OK");
}
use of okhttp3.logging.HttpLoggingInterceptor in project RxReddit by damien5314.
the class RedditService method getOkHttpClient.
protected OkHttpClient getOkHttpClient(String userAgent, int cacheSizeBytes, File cachePath, boolean loggingEnabled) {
OkHttpClient.Builder builder = new OkHttpClient.Builder().addNetworkInterceptor(new UserAgentInterceptor(userAgent)).addNetworkInterceptor(new RawResponseInterceptor()).addNetworkInterceptor(getUserAuthInterceptor());
if (cacheSizeBytes > 0) {
builder.cache(new Cache(cachePath, cacheSizeBytes));
}
if (loggingEnabled) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
builder.addInterceptor(loggingInterceptor);
}
return builder.build();
}
use of okhttp3.logging.HttpLoggingInterceptor in project TeamCityApp by vase4kin.
the class AppModule method providesBaseHttpClient.
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
@Named(CLIENT_BASE)
@Singleton
@Provides
protected OkHttpClient providesBaseHttpClient() {
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS).readTimeout(READ_TIMEOUT, TimeUnit.SECONDS).writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS);
// TODO: Use DI separated modules for debug and release which will be holding this interceptor
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
clientBuilder.addInterceptor(loggingInterceptor);
}
return clientBuilder.build();
}
Aggregations