当前位置: 首页 > news >正文

自助建网站软件平台内容网站最新好用的cms

自助建网站软件平台,内容网站最新好用的cms,互联网推广模式,网站手机页面做多大https://square.github.io/okhttp/​square.github.iosquare/okhttp​github.com0 概述okhttp是一个现代的网络请求框架Http/2 支持 所有访问同一个主机的Request都共用一个socketconnection pool 连接池 减少请求延迟GZIP 压缩数据#xff0c;减少传输所用的带宽Response Cac…https://square.github.io/okhttp/​square.github.iosquare/okhttp​github.com0 概述okhttp是一个现代的网络请求框架Http/2 支持 所有访问同一个主机的Request都共用一个socketconnection pool 连接池 减少请求延迟GZIP 压缩数据减少传输所用的带宽Response Cache 避免重复性的Request1 使用GetOkHttpClient client new OkHttpClient();String run(String url) throws IOException {Request request new Request.Builder().url(url).build();try (Response response client.newCall(request).execute()) {return response.body().string();} }Postpublic static final MediaType JSON MediaType.get(application/json; charsetutf-8);OkHttpClient client new OkHttpClient();String post(String url, String json) throws IOException {RequestBody body RequestBody.create(json, JSON);Request request new Request.Builder().url(url).post(body).build();try (Response response client.newCall(request).execute()) {return response.body().string();} }Asyncprivate final OkHttpClient client new OkHttpClient();public void run() throws Exception {Request request new Request.Builder().url(http://publicobject.com/helloworld.txt).build();client.newCall(request).enqueue(new Callback() {Override public void onFailure(Call call, IOException e) {e.printStackTrace();}Override public void onResponse(Call call, Response response) throws IOException {try (ResponseBody responseBody response.body()) {if (!response.isSuccessful()) throw new IOException(Unexpected code response);Headers responseHeaders response.headers();for (int i 0, size responseHeaders.size(); i size; i) {System.out.println(responseHeaders.name(i) : responseHeaders.value(i));}System.out.println(responseBody.string());}}});}2 源码2.0 请求过程2.1 OkHttpClientdispatcherinterceptorsnetworkInterceptorsconnectionPoolproxynewCall()2.2 CallResponse execute()enqueue(Callback responseCallback)2.3 RequesturlmethodheadersbodytagcacheControl2.4 Responserequestprotocolcodemessageheadersbodyhandshake2.5 RealInterceptorChaininterceptorstransmitterindexrequestcallexchange2.6 InterceptorResponse intercept(Chain chain)2.7 CacheDiskLruCache cache;2.8 ConnectionRoute route();Socket socket();Handshake handshake();Protocol protocol();connectSocketsourcesinkconnectionPool3 架构中间层OKhttp 通过很多中间拦截器来对 Request Response 进行加工实现了数据的 流式链式处理生产者分发器调度器 通过不同状态的 任务队列 来调度任务readyCalls runningCalls消费者缓存拦截器类似责任链的效果链式处理链式返回
http://www.zqtcl.cn/news/537827/

相关文章:

  • 几度设计网站设计制作平板电脑支架
  • 游戏设计 网站上海中企动力做网站多少钱
  • flash 开发的网站网上国网app推广经验
  • pyhton可以做网站吗文章wordpress
  • 省住房城乡建设厅门户网站电子商务网站建设用什么软件
  • 怎么给自己的网站做模版企业网站开发外包
  • 哪家可以做网站东莞网站建设少儿托管
  • 最好的网站建设公司排名生物技术网站开发
  • 网站建设经验大总结不良人网页设计怎么做
  • 宁波市余姚建设局网站学做网站要代码
  • 戴尔公司网站开发的经营目标贵州省铜仁市城乡建设局网站
  • 商务网站建设简答题及答案网站备案 域名证书
  • 网站后门怎么去除贾汪城乡建设局网站
  • 烟台住房和城乡建设厅网站重庆网站界面设计
  • 企业网站推广服务协议html编程语言
  • 上海知名网站建设公司合肥建设云平台证书查询
  • 网站响应度西安哪家公司做的网站好
  • 广州市白云区网站建设维护wordpress如何匹配模板
  • 360网站导航公司地址怎么做seo 优化一般包括哪些内容
  • 龙岗高端建设网站建设南京旅游网页设计
  • 企业网站优化问题wordpress滑动
  • 亳州网站建设费用广东网站建设报价
  • ai生成作文网站驾校网站源码下载
  • icon图标素材下载网站郑州做定制网站的公司
  • 网站建设培训哪家好北京有几个区几个县
  • 县局网站建设招标最新网页游戏传奇
  • 咋么做进网站跳转加群代理记账公司如何寻找客户
  • 可以做pos机的网站app网站建设制作
  • 手机移动端网站影视摄影传媒公司
  • 做化工资讯的网站湖南省做网站的