改进2在标题字符串末尾添加新行字符

时间:2018-03-24 22:13:30

标签: java android retrofit2 okhttp

我正在使用Retrofit v2.4,它在标题中添加了一个新的行字符,但我的调用失败

"授权:基础dXNlcm5hbWU6cGFzc3dvcmQ = \ n"

这是什么解决方案?

1 个答案:

答案 0 :(得分:0)

创建一个实现.class1 .mat-select-placeholder { color:red !important; } .class2 .mat-select-placeholder { color:blue !important; } 并覆盖okhttp3.Interceptor的类,并对标题执行任何操作,包括传出或传入:

intercept()

不要忘记将它添加到httpclient:

@Override
    public Response intercept(Chain chain) throws IOException {
        Request initialReq = chain.request();
        Headers outgoingHeaders = initialRequest.headers()
        ...
        Request modRequest = initialReq.newBuilder()
              .addHeader(...);

        Response response = chain.proceed(modRequest);
        Headers incomingHeaders = response.headers();
        ...
        return response;
}
相关问题