依赖关系

方法

class MinimalHttpClient extends CloseableHttpClient {

	//连接管理器
private final HttpClientConnectionManager connManager;
//执行器
private final MinimalClientExec requestExecutor;
//参数
private final HttpParams params;
}

doExecute方法



 @Override
protected CloseableHttpResponse doExecute(
final HttpHost target,
final HttpRequest request,
final HttpContext context) throws IOException, ClientProtocolException {
Args.notNull(target, "Target host");
Args.notNull(request, "HTTP request");
//Interface to be implemented by any object
//that wishes to be notified of blocking I/O operations
//that could be cancelled.
//blocking I/O .....
HttpExecutionAware execAware = null;
if (request instanceof HttpExecutionAware) {
execAware = (HttpExecutionAware) request;
}
try {
//HttpRequest的包装类
final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request);
final HttpClientContext localcontext = HttpClientContext.adapt(
context != null ? context : new BasicHttpContext());
//指明服务器的地址
final HttpRoute route = new HttpRoute(target);
//请求相关的基础配置
RequestConfig config = null;
if (request instanceof Configurable) {
config = ((Configurable) request).getConfig();
}
if (config != null) {
localcontext.setRequestConfig(config);
}
return this.requestExecutor.execute(route, wrapper, localcontext, execAware);
} catch (final HttpException httpException) {
throw new ClientProtocolException(httpException);
}
}

最后请求会交给MinimalClientExec 对象处理。

MinimalClientExec



基础回顾

Blocking I/O

JAVA I/O分为BIO(Blocking IO)、NIO(Non-blocking IO)和AIO(Asynchronous IO)。这里要讲到的就是Blocking I/O。

参考文档

HttpClient源码解析系列:第二篇:极简版实现

HttpClient官网 Quick Start

参考视频

一头扎进HttpClient

HttpClient学习(二)—— MinimalHttpClient源码解析的更多相关文章

  1. 深入学习 esp8266 wifimanager源码解析(打造专属自己的web配网)

    QQ技术互动交流群:ESP8266&32 物联网开发 群号622368884,不喜勿喷 单片机菜鸟博哥CSDN 1.前言 废话少说,本篇博文的目的就是深入学习 WifiManager 这个gi ...

  2. Android Handler机制(二)---MessageQueue源码解析

    MessageQueue 1.变量 private final boolean mQuitAllowed;//表示MessageQueue是否允许退出 @SuppressWarnings(" ...

  3. 通讯框架 t-io 学习——websocket 部分源码解析

    前言 前端时间看了看t-io的websocket部分源码,于是抽时间看了看websocket的握手和他的通讯机制.本篇只是简单记录一下websocket握手部分. WebSocket握手 好多人都用过 ...

  4. spring cloud深入学习(四)-----eureka源码解析、ribbon解析、声明式调用feign

    基本概念 1.Registe 一一服务注册当eureka Client向Eureka Server注册时,Eureka Client提供自身的元数据,比如IP地址.端口.运行状况指标的Uri.主页地址 ...

  5. dubbo学习 二 dubbo源码大致查阅

    源码的解析在官网都已经写的非常详细,可以参考:http://dubbo.io/Developer+Guide-zh.htm   服务提供者暴露一个服务的详细过程 首先ServiceConfig类拿到对 ...

  6. 集合类学习之ArrayList源码解析

    1.概述 ArrayList是List接口的可变数组的实现.实现了所有可选列表操作,并允许包括 null 在内的所有元素.除了实现 List 接口外,此类还提供一些方法来操作内部用来存储列表的数组的大 ...

  7. 十二.jQuery源码解析之.eq().first().last().slice()

    eq(index):将集合中的索引为index的元素提取出来. first():返回集合中的第一个元素. .last():防护集合中的最后一个元素. .slice(start[,end]):返回集合中 ...

  8. 二.jQuery源码解析之构建jQuery之构建函数jQuery的7种用法

    一:$(selectorStr[,限制范围]),接受一个选择器(符合jQuery规范的字符串),返回一个jQuery对象; 二:$(htmlStr[,文档对象]),$(html[,json对象])传入 ...

  9. Runnable、Callable、Future和FutureTask之二:源码解析

    一.Callable与Future类图 1.类图 许多任务实际上都是存在延迟的计算,对于这些任务,Callable是一种更好的抽象:它会返回一个值,并可能抛出一个异常.Callable接口: V ca ...

随机推荐

  1. js入门之内置对象Math

    一. 复习数据类型 简单数据类型, 基本数据类型/值类型 Number String Boolean Null Undefined 复杂数据类型 引用类型 Object 数组 数据在内存中是如何存储的 ...

  2. CSS重排和重绘

    一.什么是重绘Repaint和重排 (回流 reflow) 重绘:当元素的一部分属性发生改变,如外观.背景.颜色等不会引起布局变化,只需要浏览器根据元素的新属性重新绘制 ,使元素呈现新的外观叫做重绘. ...

  3. oracle 01741:非法的零长度标识

    转自:https://blog.csdn.net/wanderball/article/details/7690206 出现此问题是标识符里有两个连续的“”号,去掉即可,或是里面填充内容,避免两个连续 ...

  4. C#-FileHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. MySQL处理达到百万级数据时,如何优化?

    1.两种查询引擎查询速度(myIsam 引擎 ) InnoDB 中不保存表的具体行数,也就是说,执行select count(*) from table时,InnoDB要扫描一遍整个表来计算有多少行. ...

  6. diff算法实现

    大致流程 var vnode = { tag: 'ul', attrs: { id: 'list' }, children: [{ tag: 'li', attrs: { className: 'it ...

  7. Return local beginning of day time object in Go

    Both the title and the text of the question asked for "a local [Chicago] beginning of today tim ...

  8. CH6201 走廊泼水节[最小生成树]

    描述 [简化版题意]给定一棵N个节点的树,要求增加若干条边,把这棵树扩充为完全图,并满足图的唯一最小生成树仍然是这棵树.求增加的边的权值总和最小是多少. 我们一共有N个OIER打算参加这个泼水节,同时 ...

  9. python_面向对象——封装

    1.私有属性 class Person(object): def __init__(self,name,age): self.name = name self.age = age #实例属性 self ...

  10. XSLT可扩展样式表语言转换 System.Xml.Xsl、XslCompiledTransform类

    XML文件 books.xml: <?xml version="1.0" encoding="utf-8" ?> <bookstore> ...