1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.apache.hc.core5.http.impl;
28
29 import org.apache.hc.core5.http.protocol.HttpProcessor;
30 import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
31 import org.apache.hc.core5.http.protocol.RequestConnControl;
32 import org.apache.hc.core5.http.protocol.RequestContent;
33 import org.apache.hc.core5.http.protocol.RequestExpectContinue;
34 import org.apache.hc.core5.http.protocol.RequestTargetHost;
35 import org.apache.hc.core5.http.protocol.RequestUserAgent;
36 import org.apache.hc.core5.http.protocol.RequestValidateHost;
37 import org.apache.hc.core5.http.protocol.ResponseConnControl;
38 import org.apache.hc.core5.http.protocol.ResponseContent;
39 import org.apache.hc.core5.http.protocol.ResponseDate;
40 import org.apache.hc.core5.http.protocol.ResponseServer;
41 import org.apache.hc.core5.util.TextUtils;
42 import org.apache.hc.core5.util.VersionInfo;
43
44
45
46
47
48
49 public final class HttpProcessors {
50
51 private final static String SOFTWARE = "Apache-HttpCore";
52
53
54
55
56
57
58
59
60 public static HttpProcessorBuilder customServer(final String serverInfo) {
61 return HttpProcessorBuilder.create()
62 .addAll(
63 new ResponseDate(),
64 new ResponseServer(!TextUtils.isBlank(serverInfo) ? serverInfo :
65 VersionInfo.getSoftwareInfo(SOFTWARE, "org.apache.hc.core5", HttpProcessors.class)),
66 new ResponseContent(),
67 new ResponseConnControl())
68 .addAll(
69 new RequestValidateHost());
70 }
71
72
73
74
75
76
77
78
79 public static HttpProcessor server(final String serverInfo) {
80 return customServer(serverInfo).build();
81 }
82
83
84
85
86
87
88
89 public static HttpProcessor server() {
90 return customServer(null).build();
91 }
92
93
94
95
96
97
98
99
100 public static HttpProcessorBuilder customClient(final String agentInfo) {
101 return HttpProcessorBuilder.create()
102 .addAll(
103 new RequestContent(),
104 new RequestTargetHost(),
105 new RequestConnControl(),
106 new RequestUserAgent(!TextUtils.isBlank(agentInfo) ? agentInfo :
107 VersionInfo.getSoftwareInfo(SOFTWARE, "org.apache.hc.core5", HttpProcessors.class)),
108 new RequestExpectContinue());
109 }
110
111
112
113
114
115
116
117
118 public static HttpProcessor client(final String agentInfo) {
119 return customClient(agentInfo).build();
120 }
121
122
123
124
125
126
127
128 public static HttpProcessor client() {
129 return customClient(null).build();
130 }
131
132 }