1 package com.moiseum.wolnelektury.connection.interceptors;
3 import android.support.annotation.NonNull;
5 import java.io.IOException;
7 import okhttp3.HttpUrl;
8 import okhttp3.Interceptor;
9 import okhttp3.Request;
10 import okhttp3.Response;
13 * Created by Piotr Ostrowski on 24.09.2018.
15 public class NewApiInterceptor implements Interceptor {
17 private static final String NEW_API_HEADER = "New-Api";
18 private static final String NEW_API_PARAM = "new_api";
21 public Response intercept(@NonNull Chain chain) throws IOException {
22 if (chain.request().header(NEW_API_HEADER) != null) {
23 HttpUrl httpUrl = chain.request()
26 .addQueryParameter(NEW_API_PARAM, Boolean.toString(true))
28 Request newRequest = chain.request()
32 return chain.proceed(newRequest);
35 return chain.proceed(chain.request());