代码拉取完成,页面将自动刷新
/**
* http请求工具 委托
* 优先使用OkHttp
* 最后使用JFinal HttpKit
*/
private interface HttpDelegate {
String get(String url);
String get(String url, Map<String, String> queryParas);
String post(String url, String data);
String postSSL(String url, String data, String certPath, String certPass);
MediaFile download(String url);
InputStream download(String url, String params);
String upload(String url, File file, String params);
}
POM
中添加OkHttp3
相关的依赖即可。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
我早就添加了,但还是会只走HttpKit
请问这个问题有处理吗
我是用boot的版本,1.3.5,其中设置测试配置
@Bean
public OkHttpClient okHttpClient() {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 80));
OkHttpClient build = new OkHttpClient.Builder()
.sslSocketFactory(sslSocketFactory(), x509TrustManager())
.retryOnConnectionFailure(false)//是否开启缓存
.connectionPool(pool())//连接池
.connectTimeout(10L, TimeUnit.SECONDS)
.readTimeout(10L, TimeUnit.SECONDS)
.proxy(proxy)
.build();
return build;
}
我跑了下代码,是用到了okHttp的 不过,并没有使用原先配置的代理的,而是自己定义的连接。
根据jar探测实现类不明确,容易引起bug,给维护带来不便,以后如果想添加跟实现相关的能力时会有不便,比如监控调用链。代码表达最好是很明确。
登录 后才可以发表评论