OKHttp3如何禁用请求重定向

时间:2019-03-15 15:26:10

标签: java http okhttp3 bad-request unauthorized

我使用Apache的CloseableHttpClient发送带有错误凭据的请求,得到了预期的401,但是在OKHttp3的情况下,我收到了代码400的响应以及两个先前的401请求。

我的客户:

return new OkHttpClient.Builder()
            .followRedirects(false)
            .followSslRedirects(false)
            .retryOnConnectionFailure(false)
            .addInterceptor(new HttpLoggingInterceptor(log::trace)
                    .setLevel(HttpLoggingInterceptor.Level.HEADERS))
            .readTimeout(120, SECONDS)
            .build();

如何更改它?

0 个答案:

没有答案
相关问题