// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/LoggingInterceptor.java
// public class LoggingInterceptor implements Interceptor {
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         //这个chain里面包含了request和response，所以你要什么都可以从这里拿
//         Request request = chain.request();
//         long t1 = System.nanoTime();//请求发起的时间
// 
//         String method = request.method();
//         if ("POST".equals(method)) {
//             StringBuilder sb = new StringBuilder();
//             if (request.body() instanceof FormBody) {
//                 FormBody body = (FormBody) request.body();
//                 for (int i = 0; i < body.size(); i++) {
//                     sb.append(body.encodedName(i) + "=" + body.encodedValue(i) + ",");
//                 }
//                 sb.delete(sb.length() - 1, sb.length());
//                 Log.d("CSDN_LQR", String.format("发送请求 %s on %s %n%s %nRequestParams:{%s}",
//                         request.url(), chain.connection(), request.headers(), sb.toString()));
//             }
//         } else {
//             Log.d("CSDN_LQR", String.format("发送请求 %s on %s%n%s",
//                     request.url(), chain.connection(), request.headers()));
//         }
//         Response response = chain.proceed(request);
//         long t2 = System.nanoTime();//收到响应的时间
//         //这里不能直接使用response.body().string()的方式输出日志
//         //因为response.body().string()之后，response中的流会被关闭，程序会报错，我们需要创建出一
//         //个新的response给应用层处理
//         ResponseBody responseBody = response.peekBody(1024 * 1024);
//         Log.d("CSDN_LQR",
//                 String.format("接收响应: [%s] %n返回json:【%s】 %.1fms %n%s",
//                         response.request().url(),
//                         responseBody.string(),
//                         (t2 - t1) / 1e6d,
//                         response.headers()
//                 ));
//         return response;
//     }
// }
// 
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java
// public class UserAgentInterceptor implements Interceptor {
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         Request originalRequest = chain.request();
//         Request requestWithUserAgent = originalRequest.newBuilder()
//                 .removeHeader("User-Agent")
//                 .addHeader("User-Agent", Api.COMMON_UA_STR)
//                 .build();
//         return chain.proceed(requestWithUserAgent);
//     }
// }


import android.content.Context;
import com.jess.arms.di.module.ClientModule;
import com.lqr.biliblili.BuildConfig;
import com.lqr.biliblili.app.config.applyOptions.intercept.LoggingInterceptor;
import com.lqr.biliblili.app.config.applyOptions.intercept.UserAgentInterceptor;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
package com.lqr.biliblili.app.config.applyOptions;





public class MyRetrofitConfiguration implements ClientModule.RetrofitConfiguration {
    @Override
    public void configRetrofit(Context context, Retrofit.Builder builder) {
        // 配置多BaseUrl支持
        OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
        if (BuildConfig.DEBUG) {
            clientBuilder.addInterceptor(new LoggingInterceptor());//使用自定义的Log拦截器
        }
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/LoggingInterceptor.java
// public class LoggingInterceptor implements Interceptor {
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         //这个chain里面包含了request和response，所以你要什么都可以从这里拿
//         Request request = chain.request();
//         long t1 = System.nanoTime();//请求发起的时间
// 
//         String method = request.method();
//         if ("POST".equals(method)) {
//             StringBuilder sb = new StringBuilder();
//             if (request.body() instanceof FormBody) {
//                 FormBody body = (FormBody) request.body();
//                 for (int i = 0; i < body.size(); i++) {
//                     sb.append(body.encodedName(i) + "=" + body.encodedValue(i) + ",");
//                 }
//                 sb.delete(sb.length() - 1, sb.length());
//                 Log.d("CSDN_LQR", String.format("发送请求 %s on %s %n%s %nRequestParams:{%s}",
//                         request.url(), chain.connection(), request.headers(), sb.toString()));
//             }
//         } else {
//             Log.d("CSDN_LQR", String.format("发送请求 %s on %s%n%s",
//                     request.url(), chain.connection(), request.headers()));
//         }
//         Response response = chain.proceed(request);
//         long t2 = System.nanoTime();//收到响应的时间
//         //这里不能直接使用response.body().string()的方式输出日志
//         //因为response.body().string()之后，response中的流会被关闭，程序会报错，我们需要创建出一
//         //个新的response给应用层处理
//         ResponseBody responseBody = response.peekBody(1024 * 1024);
//         Log.d("CSDN_LQR",
//                 String.format("接收响应: [%s] %n返回json:【%s】 %.1fms %n%s",
//                         response.request().url(),
//                         responseBody.string(),
//                         (t2 - t1) / 1e6d,
//                         response.headers()
//                 ));
//         return response;
//     }
// }
// 
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java
// public class UserAgentInterceptor implements Interceptor {
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         Request originalRequest = chain.request();
//         Request requestWithUserAgent = originalRequest.newBuilder()
//                 .removeHeader("User-Agent")
//                 .addHeader("User-Agent", Api.COMMON_UA_STR)
//                 .build();
//         return chain.proceed(requestWithUserAgent);
//     }
// }


// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/MyRetrofitConfiguration.java
import android.content.Context;
import com.jess.arms.di.module.ClientModule;
import com.lqr.biliblili.BuildConfig;
import com.lqr.biliblili.app.config.applyOptions.intercept.LoggingInterceptor;
import com.lqr.biliblili.app.config.applyOptions.intercept.UserAgentInterceptor;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;

package com.lqr.biliblili.app.config.applyOptions;





public class MyRetrofitConfiguration implements ClientModule.RetrofitConfiguration {
    @Override
    public void configRetrofit(Context context, Retrofit.Builder builder) {
        // 配置多BaseUrl支持
        OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
        if (BuildConfig.DEBUG) {
            clientBuilder.addInterceptor(new LoggingInterceptor());//使用自定义的Log拦截器
        }
        clientBuilder.addInterceptor(new UserAgentInterceptor());//使用自定义User-Agent