美文网首页
1、okhttp源码解析-整体流程

1、okhttp源码解析-整体流程

作者: 飞奔的口罩 | 来源:发表于2020-08-19 14:37 被阅读0次

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 {

    }
});

二、调用流程图

okhttp (2).png

相关文章

网友评论

      本文标题:1、okhttp源码解析-整体流程

      本文链接:https://www.haomeiwen.com/subject/xunrjktx.html