一、HttpRequst执行流程图
理解:
1、HttpProcessor是HTTP protocol processor的缩写,它的作用就是给我们写的request设置默认参数(比如协议版本,是否保持连接等),一般我们写的HttpRequest只有url和数据,事实上,一个完整的请求不只有这两个数据,查看一下HTTP协议就知道一个请求需要很多数据了,而之所以我们不用写这些数据,是因为HttpCore或HttpClient帮我们完成了,而负责这部分功能的就是HttpProcessor。
2、HttpRequestExecutor 的作用就是调用HttpProcessor完善原始HttpRequest,根据请求参数使用HttpClientConnection执行HttpRequest并接受HttpResponse,以及设置HttpCoreContext参数。
3、HttpClientConnection获取方法有两种:1、自己新建conn绑定根据host新建的socket;2、新建connpool,根据host从pool中获取conn
4、HttpCoreContext:是为了完成会话功能,下边是官方注释:
* The primary purpose of the HTTP context is to facilitate information sharing * among various logically related components. HTTP context can be used * to store a processing state for one message or several consecutive messages. * Multiple logically related messages can participate in a logical session * if the same context is reused between consecutive messages.
二、HttpResponse的获取原理