use of okhttp3.logging.HttpLoggingInterceptor in project iNGAGE by davis123123.
the class UserInfoHandler method enqueue.
public void enqueue(String username, String ip) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
String url = "http://" + ip + "/user_profile.php/";
Retrofit retrofit = new Retrofit.Builder().client(httpClient.build()).addConverterFactory(GsonConverterFactory.create()).baseUrl(url).build();
Interface service = retrofit.create(Interface.class);
Call<ResponseBody> call = service.get(username, url);
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 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class ServiceGenerator method createService.
public static <S> S createService(Class<S> serviceClass, Context context) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
if (BuildConfig.DEBUG) {
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
logging.setLevel(HttpLoggingInterceptor.Level.NONE);
}
PersistentCookieStore cookieStore = new PersistentCookieStore(context);
java.net.CookieManager cookieManager = new java.net.CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder().cookieJar(new JavaNetCookieJar(cookieManager)).addInterceptor(logging).addNetworkInterceptor(new StethoInterceptor());
Gson gson = new GsonBuilder().setLenient().create();
Retrofit retorfit = new Retrofit.Builder().baseUrl(MafiaRemoteService.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).client(httpClient.build()).build();
return retorfit.create(serviceClass);
}
use of okhttp3.logging.HttpLoggingInterceptor in project Cobinhood.Java by jd-alexander.
the class TradingTests method setup.
@Before
public void setup() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
cobinhoodService = new CobinhoodApi.Builder().setLoggingInterceptor(logging).setAccessToken(BuildConfig.API_KEY).build();
}
use of okhttp3.logging.HttpLoggingInterceptor in project FastHub by k0shk0sh.
the class JsoupProvider method provideOkHttpClient.
private 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(true));
okHttpClient = client.build();
}
return okHttpClient;
}
use of okhttp3.logging.HttpLoggingInterceptor in project FastHub by k0shk0sh.
the class ImgurProvider method provideOkHttpClient.
private static OkHttpClient provideOkHttpClient() {
OkHttpClient.Builder client = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
client.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY));
}
client.addInterceptor(chain -> {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder();
requestBuilder.header("Authorization", "Client-ID " + BuildConfig.IMGUR_CLIENT_ID);
requestBuilder.method(original.method(), original.body());
Request request = requestBuilder.build();
return chain.proceed(request);
});
return client.build();
}
Aggregations