okhttp禁止重定向

followRedirects(false)

    private OkHttpClient getOkHttpClient() {
        if (client == null) {
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
            httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            client = new OkHttpClient.Builder()
                    .writeTimeout(20, TimeUnit.SECONDS)
                    .connectTimeout(5, TimeUnit.SECONDS)
                    .readTimeout(30, TimeUnit.SECONDS)
                    .addInterceptor(httpLoggingInterceptor)
                    .followRedirects(false)
                    .build();
        }
        return client;
    }

相关文章:

  • 2021-10-21
  • 2021-06-06
  • 2021-08-11
  • 2021-09-28
  • 2021-12-19
  • 2021-10-16
  • 2021-06-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2022-12-23
  • 2022-02-22
相关资源
相似解决方案