MCPcopy Create free account
hub / github.com/SeanDragon/protools / HttpBuilder

Class HttpBuilder

http/src/main/java/pro/tools/http/jdk/HttpBuilder.java:11–181  ·  view source on GitHub ↗

http客户端的工厂类 @author SeanDragon Create By 2017-04-07 14:59

Source from the content-addressed store, hash-verified

9 * @author SeanDragon Create By 2017-04-07 14:59
10 */
11public final class HttpBuilder {
12
13 /**
14 * 异步http客户端的工厂构造对象
15 */
16 private AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder();
17
18 /**
19 * 最大请求重连次数
20 */
21 private int maxRequestRetry = 10;
22 /**
23 * 最大连接数
24 */
25 private int maxConnections = 1000;
26
27 /**
28 * 连接池开关
29 */
30 private boolean allowPollingConnections = true;
31 /**
32 * 重定向追踪开关
33 */
34 private boolean followRedirect = true;
35 /**
36 * 压缩请求开关
37 */
38 private boolean compressionEnforced = true;
39
40 /**
41 * 重定向次数限制
42 */
43 private int maxRedirects = 3;
44 /**
45 * 连接超时时间
46 */
47 private int connectTimeout = 200;
48 /**
49 * 读取请求超时间时间
50 */
51 private int readTimeout = 200;
52 /**
53 * 初始化连接池大小
54 */
55 private int maxConnectionsPerHost = 100;
56 /**
57 * 用于IO的线程数
58 */
59 private int ioThreadMultiplier = 10;
60
61 /**
62 * UserAgent
63 */
64 private String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36";
65
66 AsyncHttpClient buildDefaultClient() {
67 builder.setMaxRequestRetry(maxRequestRetry)//尝试重试次数
68 .setAllowPoolingConnections(allowPollingConnections)//开启连接池模式

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected