参考这个链接
但是我这样做了还是无效
请求的时候
报stream was reset: PROTOCOL_ERROR
错误
最后google了一下,在OkHttpClient中加了一行代码才有效
OkHttpClient httpClient = new OkHttpClient.Builder()
.addInterceptor(new Interceptor() {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
Request request = chain.request()
.newBuilder()
.addHeader("SdkVersion", "1")
.addHeader("Authorization", BaseApplication.getInstance().getToken())
.addHeader("Model", BaseApplication.getInstance().getModel())
.build();
return chain.proceed(request);
}
})
.sslSocketFactory(getSSLSocketFactory(BaseApplication.getInstance()))
//加上这行代码https才有效
.protocols(Collections.singletonList(Protocol.HTTP_1_1))
.build();