38
38
/**
39
39
* Thread-safe HTTP transport based on the Apache HTTP Client library.
40
40
*
41
- * <p>
42
- * Implementation is thread-safe, as long as any parameter modification to the
43
- * {@link #getHttpClient() Apache HTTP Client} is only done at initialization time. For maximum
44
- * efficiency, applications should use a single globally-shared instance of the HTTP transport.
45
- * </p>
41
+ * <p>Implementation is thread-safe, as long as any parameter modification to the {@link
42
+ * #getHttpClient() Apache HTTP Client} is only done at initialization time. For maximum efficiency,
43
+ * applications should use a single globally-shared instance of the HTTP transport.
46
44
*
47
- * <p>
48
- * Default settings are specified in {@link #newDefaultHttpClient()}. Use the
49
- * {@link #ApacheHttpTransport(HttpClient)} constructor to override the Apache HTTP Client used.
50
- * Please read the <a
45
+ * <p>Default settings are specified in {@link #newDefaultHttpClient()}. Use the {@link
46
+ * #ApacheHttpTransport(HttpClient)} constructor to override the Apache HTTP Client used. Please
47
+ * read the <a
51
48
* href="http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html">Apache HTTP
52
49
* Client connection management tutorial</a> for more complex configuration options.
53
- * </p>
54
50
*
55
51
* @since 1.30
56
52
* @author Yaniv Inbar
@@ -72,41 +68,38 @@ public ApacheHttpTransport() {
72
68
/**
73
69
* Constructor that allows an alternative Apache HTTP client to be used.
74
70
*
75
- * <p>
76
- * Note that in the previous version, we overrode several settings. However, we are no longer able
77
- * to do so.
78
- * </p>
71
+ * <p>Note that in the previous version, we overrode several settings. However, we are no longer
72
+ * able to do so.
73
+ *
74
+ * <p>If you choose to provide your own Apache HttpClient implementation, be sure that
79
75
*
80
- * <p>If you choose to provide your own Apache HttpClient implementation, be sure that</p>
81
76
* <ul>
82
- * <li>HTTP version is set to 1.1.</li>
83
- * <li>Redirects are disabled (google-http-client handles redirects).</li>
84
- * <li>Retries are disabled (google-http-client handles retries).</li>
77
+ * <li>HTTP version is set to 1.1.
78
+ * <li>Redirects are disabled (google-http-client handles redirects).
79
+ * <li>Retries are disabled (google-http-client handles retries).
85
80
* </ul>
86
81
*
87
82
* @param httpClient Apache HTTP client to use
88
- *
89
83
* @since 1.30
90
84
*/
91
85
public ApacheHttpTransport (HttpClient httpClient ) {
92
86
this .httpClient = httpClient ;
93
87
}
94
88
95
89
/**
96
- * Creates a new instance of the Apache HTTP client that is used by the
97
- * {@link #ApacheHttpTransport()} constructor.
90
+ * Creates a new instance of the Apache HTTP client that is used by the {@link
91
+ * #ApacheHttpTransport()} constructor.
92
+ *
93
+ * <p>Settings:
98
94
*
99
- * <p>
100
- * Settings:
101
- * </p>
102
95
* <ul>
103
- * <li>The client connection manager is set to {@link PoolingHttpClientConnectionManager}.</li>
104
- * <li><The retry mechanism is turned off using
105
- * {@link HttpClientBuilder#disableRedirectHandling}.</li>
106
- * <li>The route planner uses {@link SystemDefaultRoutePlanner} with
107
- * {@link ProxySelector#getDefault()}, which uses the proxy settings from <a
108
- * href="https://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html">system
109
- * properties</a>.</li>
96
+ * <li>The client connection manager is set to {@link PoolingHttpClientConnectionManager}.
97
+ * <li><The retry mechanism is turned off using {@link
98
+ * HttpClientBuilder#disableRedirectHandling}.
99
+ * <li>The route planner uses {@link SystemDefaultRoutePlanner} with {@link
100
+ * ProxySelector#getDefault()}, which uses the proxy settings from <a
101
+ * href="https://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html">system
102
+ * properties</a>.
110
103
* </ul>
111
104
*
112
105
* @return new instance of the Apache HTTP client
@@ -117,20 +110,19 @@ public static HttpClient newDefaultHttpClient() {
117
110
}
118
111
119
112
/**
120
- * Creates a new Apache HTTP client builder that is used by the
121
- * {@link #ApacheHttpTransport()} constructor.
113
+ * Creates a new Apache HTTP client builder that is used by the {@link #ApacheHttpTransport()}
114
+ * constructor.
115
+ *
116
+ * <p>Settings:
122
117
*
123
- * <p>
124
- * Settings:
125
- * </p>
126
118
* <ul>
127
- * <li>The client connection manager is set to {@link PoolingHttpClientConnectionManager}.</li>
128
- * <li><The retry mechanism is turned off using
129
- * {@link HttpClientBuilder#disableRedirectHandling}.</li>
130
- * <li>The route planner uses {@link SystemDefaultRoutePlanner} with
131
- * {@link ProxySelector#getDefault()}, which uses the proxy settings from <a
132
- * href="http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html">system
133
- * properties</a>.</li>
119
+ * <li>The client connection manager is set to {@link PoolingHttpClientConnectionManager}.
120
+ * <li><The retry mechanism is turned off using {@link
121
+ * HttpClientBuilder#disableRedirectHandling}.
122
+ * <li>The route planner uses {@link SystemDefaultRoutePlanner} with {@link
123
+ * ProxySelector#getDefault()}, which uses the proxy settings from <a
124
+ * href="http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html">system
125
+ * properties</a>.
134
126
* </ul>
135
127
*
136
128
* @return new instance of the Apache HTTP client
@@ -139,14 +131,14 @@ public static HttpClient newDefaultHttpClient() {
139
131
public static HttpClientBuilder newDefaultHttpClientBuilder () {
140
132
141
133
return HttpClientBuilder .create ()
142
- .useSystemProperties ()
143
- .setSSLSocketFactory (SSLConnectionSocketFactory .getSocketFactory ())
144
- .setMaxConnTotal (200 )
145
- .setMaxConnPerRoute (20 )
146
- .setConnectionTimeToLive (-1 , TimeUnit .MILLISECONDS )
147
- .setRoutePlanner (new SystemDefaultRoutePlanner (ProxySelector .getDefault ()))
148
- .disableRedirectHandling ()
149
- .disableAutomaticRetries ();
134
+ .useSystemProperties ()
135
+ .setSSLSocketFactory (SSLConnectionSocketFactory .getSocketFactory ())
136
+ .setMaxConnTotal (200 )
137
+ .setMaxConnPerRoute (20 )
138
+ .setConnectionTimeToLive (-1 , TimeUnit .MILLISECONDS )
139
+ .setRoutePlanner (new SystemDefaultRoutePlanner (ProxySelector .getDefault ()))
140
+ .disableRedirectHandling ()
141
+ .disableAutomaticRetries ();
150
142
}
151
143
152
144
@ Override
0 commit comments