use of okhttp3.logging.HttpLoggingInterceptor in project MovieGuide by esoxjem.
the class NetworkModule method provideOkHttpClient.
@Provides
@Singleton
OkHttpClient provideOkHttpClient() {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
return new okhttp3.OkHttpClient.Builder().connectTimeout(CONNECT_TIMEOUT_IN_MS, TimeUnit.MILLISECONDS).addInterceptor(loggingInterceptor).build();
}
use of okhttp3.logging.HttpLoggingInterceptor in project WordPress-Android by wordpress-mobile.
the class GravatarApi method createClient.
private static OkHttpClient createClient(final String accessToken) {
OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
//// uncomment the following line to add logcat logging
//httpClientBuilder.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY));
// add oAuth token usage
httpClientBuilder.addInterceptor(new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder().header("Authorization", "Bearer " + accessToken).method(original.method(), original.body());
Request request = requestBuilder.build();
return chain.proceed(request);
}
});
return httpClientBuilder.build();
}
use of okhttp3.logging.HttpLoggingInterceptor in project iNGAGE by davis123123.
the class UserInfoHandler method enqueue.
public void enqueue(String username) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
Log.i("STATE", "Retrofit url" + get_url);
Retrofit retrofit = new Retrofit.Builder().client(httpClient.build()).addConverterFactory(GsonConverterFactory.create()).baseUrl(get_url).build();
Interface service = retrofit.create(Interface.class);
Call<ResponseBody> call = service.get(username);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
Log.i("STATE", "Retrofit response code: " + response.code());
if (response.isSuccessful()) {
Log.i("STATE", "Retrofit POST Success");
try {
serverResponse = response.body().string();
callBackData.notifyChange(serverResponse);
} catch (IOException e) {
e.printStackTrace();
}
} else {
Log.i("Retrofit Error Code:", String.valueOf(response.code()));
Log.i("Retrofit Error Body", response.errorBody().toString());
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.i("STATE", "Retrofit Failure");
}
});
}
use of okhttp3.logging.HttpLoggingInterceptor in project IITB-App by wncc.
the class ServiceGenerator method createService.
public static <S> S createService(Class<S> serviceClass) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
retrofit = retrofitBuilder.client(clientBuilder.addInterceptor(httpLoggingInterceptor).build()).build();
return retrofit.create(serviceClass);
}
use of okhttp3.logging.HttpLoggingInterceptor in project Palm300Heroes by nicolite.
the class RetrofitUtils method okHttpClient.
/**
* 配置OkHttp
*
* @return OkHttpClient
*/
private static OkHttpClient okHttpClient() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public void log(@NonNull String message) {
LogUtils.d(TAG, "okHttp:" + message);
}
});
logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
return new OkHttpClient.Builder().connectTimeout(CONNECT_TIME_OUT, TimeUnit.SECONDS).writeTimeout(WRITE_TIME_OUT, TimeUnit.SECONDS).readTimeout(READ_TIME_OUT, TimeUnit.SECONDS).addInterceptor(logging).build();
}
Aggregations