okhttp基本使用
2016-05-07 02:43
399 查看
okhttp 基本使用
先看看几个重要的类
public final class Request {
private final HttpUrl url;
private final String method;
private final Headers headers;
private final RequestBody body;
private final Object tag;
…
}
public final class Response {
private final Request request;
private final Protocol protocol;
private final int code;
private final String message;
private final Handshake handshake;
private final Headers headers;
private final ResponseBody body;
private Response networkResponse;
private Response cacheResponse;
private final Response priorResponse;
…
}
使用步骤
1. OkHttpClient client= new OkHttpClient();
2. Request request = new Request.Builder().
url(“http://www.baidu.com“).
build();
3.Call call = client.newCall(request);
4. Response response=call.execute();
先看看几个重要的类
public final class Request {
private final HttpUrl url;
private final String method;
private final Headers headers;
private final RequestBody body;
private final Object tag;
…
}
public final class Response {
private final Request request;
private final Protocol protocol;
private final int code;
private final String message;
private final Handshake handshake;
private final Headers headers;
private final ResponseBody body;
private Response networkResponse;
private Response cacheResponse;
private final Response priorResponse;
…
}
使用步骤
1. OkHttpClient client= new OkHttpClient();
2. Request request = new Request.Builder().
url(“http://www.baidu.com“).
build();
3.Call call = client.newCall(request);
4. Response response=call.execute();
相关文章推荐
- TCP窗口滑动以及拥塞控制
- Redhat 7使用CentOS 7的Yum网络源
- Okhttp的高效使用方式
- Qt 嵌入式 利用wpa_supplicant编写WIFI、有线网络管理器
- 国外网络穿透到国内看国内优酷爱奇艺等视频
- 网络连接 002
- iOS开发用AFNetworking和MJRefresh实现网络请求和下拉刷新、上拉加载
- Python网络数据获取(metplotlib/pandas)
- tcpdump用法
- 20145327实验五 Java网络编程
- 网络请求遇到的一个问题
- 5-项目进度管理和项目成本管理
- [javaSE] 网络编程(UDP通信)
- [转] ASP.NET WEB API程序在VS启动或发布到IIS后启动后发生 - Could not load file or assembly 'System.Web.Http.WebHost’异常,无法正常访问
- HTTPS
- Nginx环境中如何将HTTP跳转至HTTPS设置
- iOS网络数据请求
- 网络爬虫
- Android获取网络图片的三种方法
- 网络请求库的代码迁移