# easy-http-client **Repository Path**: wxl0209/easy-http-client ## Basic Information - **Project Name**: easy-http-client - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-08-03 - **Last Updated**: 2021-03-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 基于 netty 构建的 http 客户端 ### 项目源于 项目使于 2018.06 月,历时半个月,需要模拟多个请求,满足一定的请求条件后方可调用服务,为了爬取数据接口。项目完成后没有经过多少测试,并且因为一些原因放弃了业务应用,至此没再维护过。 ### 功能 1. 请求过程中可以管理当前会话的 cookie 2. 请求中可以添加任意 header 和 params 3. 自动重定向判断 4. 支持并发调用 5. 响应回调处理,可以承接前一个请求做进一步的调用或其它处理。 ``` HttpClientFactory.getClient().get(). setURL("https://xxx.domain.com/index.htm"). addHeaders(HeaderFactory.EASY_INDEX). execute(new ResponseHandler() { @Override protected Object convert(HttpResponseStatus status, HttpHeaders headers, ByteBuf content) { // 转换成期望有类型 return null; } @Override protected boolean receive(HttpResponseStatus status, CookieStore cookieStore, HttpHeaders headers, String object) { // 接收响应处理 return false; } @Override protected void next(HttpClient client, String object, CookieStore cookieStore, HttpHeaders headers) { // 消息接收之后是否需要发起下一步处理,比如再发起一个http请求 } @Override protected void onErrorResponse(HttpResponseStatus status, HttpHeaders headers, String content) { // 错误消息处理 } }); ```