OkHttp 2.0
来源:互联网 发布:淘宝店面装修多少钱 编辑:程序博客网 时间:2024/06/07 02:47
转载自:https://publicobject.com/2014/05/24/okhttp-2-0-rc1/
Adrian, Jake and I have been working on OkHttp 2.0 quite actively for nearly a year, and we're finally ready to share its new API with the world:
OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://square.com/") .build();Response response = client.newCall(request).execute(); System.out.println(response.body().string());
The 2.0 API leverages fluent builders and immutability to make HTTP easy. It can be used synchronously (above) or asynchronously:
OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://square.com") .build();client.newCall(request).enqueue(new Callback() { @Override public void onResponse(Response response) throws IOException { System.out.println(response.body().string()); } @Override public void onFailure(Request r, Throwable e) { ... }});
It shares the same sophisticated backend as ourHttpURLConnection
API which moved to a new okhttp-urlconnection
artifact.
OkHttp 2.0 is not backwards-compatible. The changelog describes what's changed and what's gone. To make upgrading easier, we're also releasing OkHttp 1.6 which is the 1.5 code plus some new 2.0 APIs. Use 1.6 to transition to 2.x APIs.
Today we're publishing a release-candidate with the goal of a final release in June. Between now and then we're going to update the examples, complete the documentation, and fix any bugs that are reported.
Get 2.0.0-RC1 from Maven Central:
<dependency> <groupId>com.squareup.okhttp</groupId> <artifactId>okhttp</artifactId> <version>2.0.0-RC1</version></dependency>
or Gradle:
compile 'com.squareup.okhttp:okhttp:2.3.0'
- OkHttp 2.0
- Retrofit 2.0 + OkHttp 3.0
- OkHttp
- okhttp
- OkHttp
- OkHttp
- OkHttp
- okhttp
- OKHTTP
- okhttp
- Okhttp
- okHttp
- OkHttp
- okhttp
- Okhttp
- okhttp
- OkHttp
- okhttp
- OpenCV中feature2D学习——FAST特征点检测与SIFT/SURF/BRIEF特征提取与匹配
- Medoo入门:安装和配置-Medoo使用指南
- Android 国内集成使用谷歌地图
- 【C++基础之十】友元函数和友元类
- BAT及各大互联网公司2014前端笔试面试题--Html,Css篇
- OkHttp 2.0
- android应用程序如何调用支付宝接口
- MyEclipse安装插件的几种方法
- 求二叉树第k层节点个数
- Spring Security使用总结(高级
- PowerDesigner导出oracle数据库表SQL文时带双引号
- zookeeper机制原理
- C语言字符串操作总结大全(超详细)
- Android Studio 小知识 文件无法读写解决