1、okhttp源码解析-整体流程
2、okhttp源码解析-拦截器RetryAndFllowUpInterceptor
3、okhttp源码解析-拦截器BridgeInterceptor
4、okhttp源码解析-拦截器CacheInterceptor
5、okhttp源码解析-拦截器ConnectInterceptor
6、okhttp源码解析-拦截器CallServerInterceptor
7、okhttp源码解析-Dispatcher任务管理器
一、简单使用
1、post方式请求体
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), "");
2、创建请求对象
Request request = new Request.Builder()
.url("")
.addHeader("", "")
.post(requestBody)
.build();
3、Okhttp工具类,发起异步请求
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
}
});
网友评论