当前位置: 首页>>代码示例>>Java>>正文


Java OkHttpClient.setFollowRedirects方法代码示例

本文整理汇总了Java中com.squareup.okhttp.OkHttpClient.setFollowRedirects方法的典型用法代码示例。如果您正苦于以下问题:Java OkHttpClient.setFollowRedirects方法的具体用法?Java OkHttpClient.setFollowRedirects怎么用?Java OkHttpClient.setFollowRedirects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.okhttp.OkHttpClient的用法示例。


在下文中一共展示了OkHttpClient.setFollowRedirects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: okHttp2Client

import com.squareup.okhttp.OkHttpClient; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean
public OkHttpClient okHttp2Client() throws IOException {
    OkHttpClient okHttpClient = new OkHttpClient();

    if (properties.getCache().getMode() != OkHttpProperties.Cache.Mode.NONE) {
        okHttpClient.setCache(okHttp2Cache());
    }

    if (cookieHandler != null) {
        okHttpClient.setCookieHandler(cookieHandler);
    }

    OkHttpProperties.Timeout connectTimeout = properties.getConnectTimeout();
    if (connectTimeout != null) {
        okHttpClient.setConnectTimeout(connectTimeout.getValue(), connectTimeout.getUnit());
    }

    OkHttpProperties.Timeout readTimeout = properties.getReadTimeout();
    if (readTimeout != null) {
        okHttpClient.setReadTimeout(readTimeout.getValue(), readTimeout.getUnit());
    }

    OkHttpProperties.Timeout writeTimeout = properties.getWriteTimeout();
    if (writeTimeout != null) {
        okHttpClient.setWriteTimeout(writeTimeout.getValue(), writeTimeout.getUnit());
    }

    if (dns != null) {
        okHttpClient.setDns(dns);
    }

    okHttpClient.setFollowRedirects(properties.isFollowRedirects());
    okHttpClient.setFollowSslRedirects(properties.isFollowSslRedirects());
    okHttpClient.setRetryOnConnectionFailure(properties.isRetryOnConnectionFailure());

    if (applicationInterceptors != null && !applicationInterceptors.isEmpty()) {
        okHttpClient.interceptors().addAll(applicationInterceptors);
    }

    if (networkInterceptors != null && !networkInterceptors.isEmpty()) {
        okHttpClient.networkInterceptors().addAll(networkInterceptors);
    }

    if (configurers != null) {
        for (Configurer<OkHttpClient> configurer : configurers) {
            configurer.configure(okHttpClient);
        }
    }

    return okHttpClient;
}
 
开发者ID:freefair,项目名称:okhttp-spring-boot,代码行数:53,代码来源:OkHttp2AutoConfiguration.java


注:本文中的com.squareup.okhttp.OkHttpClient.setFollowRedirects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。