Apache httpclient的execute方法调试
2023-09-14 09:03:09 时间
因为工作需要,想研究一下execute执行的逻辑。
在这一行调用execute:
response = getHttpClient().execute(get);
getHttpClient的实现:
private HttpClient getHttpClient() {
if (this.m_httpClient == null) {
this.m_httpClient = HttpClientBuilder.create().build();
}
return this.m_httpClient;
}
我在代码里声明的HttpClient只是一个接口,
![](https://user-images.githubusercontent.com/5669954/60192465-7052b500-9868-11e9-961e-2c820a59d230.png)
实现类是InternalHttpClient。
![](https://user-images.githubusercontent.com/5669954/60192433-67fa7a00-9868-11e9-89ae-8bd69f6a948f.png)
首先根据传入的请求决定出目标-target host
![](https://user-images.githubusercontent.com/5669954/60192435-68931080-9868-11e9-8171-ad7fe6d9677b.png)
投递到RedirectExec执行。
![](https://user-images.githubusercontent.com/5669954/60192437-68931080-9868-11e9-844d-142628a2a42f.png)
后者又投递到RetryExec执行。
![](https://user-images.githubusercontent.com/5669954/60192439-692ba700-9868-11e9-9504-7a73ae838114.png)
收到307重定向:
![](https://user-images.githubusercontent.com/5669954/60192443-69c43d80-9868-11e9-8b0e-bae2faa5e253.png)
redirectsEnabled标志位为true:
![](https://user-images.githubusercontent.com/5669954/60192447-6a5cd400-9868-11e9-9cb7-498c9b9f53b2.png)
再看当前的请求确实被redirect了吗?
![](https://user-images.githubusercontent.com/5669954/60192450-6cbf2e00-9868-11e9-9208-5e474fb1f28e.png)
original url:
![](https://user-images.githubusercontent.com/5669954/60192451-6cbf2e00-9868-11e9-9928-a2c515599ddb.png)
我的后台服务器返回的307,落到了分支HttpStatus.SC_TEMPORARY_REDIRECT处:
![](https://user-images.githubusercontent.com/5669954/60192452-6d57c480-9868-11e9-9ec2-9c94ed0effca.png)
看来Apache的库认为只有HEAD和GET才能被redirect:
![](https://user-images.githubusercontent.com/5669954/60192454-6df05b00-9868-11e9-8ed9-f0a1e84095dc.png)
重定向最大次数:50
![](https://user-images.githubusercontent.com/5669954/60192460-6f218800-9868-11e9-87f5-ef0f7bc8c87e.png)
准备重试了:
![](https://user-images.githubusercontent.com/5669954/60192464-6fba1e80-9868-11e9-9edf-80f2319884a9.png)
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关文章
- Apache Druid介绍
- 1.使用Apache Jmeter对应用压力测试学习与实践
- [实用][更新中]Java Apache POI 打印Word文档工具(含文本替换,动态表格功能)
- apache的安装教程详解_怎么安装apache
- 医疗在线OLAP场景下基于Apache Hudi 模式演变的改造与应用
- Apache Tomcat服务部署网站
- apache 的虚拟主机功能
- API 网关 Apache APISIX 3.0 版本正式发布!功能丰富
- 两个IP实现IIS和Apache公用80端口的设置方法
- SQL开发知识:使用 Apache Superset 可视化 ClickHouse 数据的方法
- 一个封装的使用Apache HttpClient进行Http请求(GET、POST、PUT等)的类。详解编程语言
- apache用Linux服务器架设QQ五笔输入法服务:基于Apache技术(qq五笔linux)
- 解决多种web问题Linux下Apache解决多种Web问题:让你的网络更安全可靠(linux下apache)
- Linux安装配置LAMP服务器(Apache+PHP5+MySQL)
- Apache安装MySQL数据库的指南(apache装mysql)
- 新版mysql+apache+phpLinux安装指南
- PHP+APACHE实现用户论证的方法
- 基于Apache的支持.NET2.0的Web服务器搭建
- xampp中apache在windows7下无法启动的解决方法
- Linux下Apache安装/增加mod_rewrite模块的方法
- windows下实现定时重启Apache与MySQL方法
- Windows下Apache应用环境塔建安全设置(目录权限设置)
- PHP正确配置mysql(apache环境)
- nginx与apache限制ip并发访问限制ip连接的设置方法
- apache设置自动将http跳转到https的方法
- LNAMP架构中后端Apache获取用户真实IP地址的2种方法
- Apache服务器关闭TRACEMethod请求方式的方法
- WampServer下安装多个版本的PHP、mysql、apache图文教程