Expose the default HttpClientBuilder so users can customize further
@@ -123,6 +123,31 @@ public final class ApacheHttpTransport extends HttpTransport {
* @since 1.30
*/
public static HttpClient newDefaultHttpClient() {
+ return newDefaultHttpClientBuilder().build();
+ }
+
+ /**
+ * Creates a new Apache HTTP client builder that is used by the
+ * {@link #ApacheHttpTransport()} constructor.
+ *
+ * <p>
+ * Settings:
+ * </p>
+ * <ul>
+ * <li>The client connection manager is set to {@link PoolingHttpClientConnectionManager}.</li>
+ * <li>The socket buffer size is set to 8192 using {@link SocketConfig}.</li>
+ * <li><The retry mechanism is turned off using
+ * {@link HttpClientBuilder#disableRedirectHandling}.</li>
+ * <li>The route planner uses {@link SystemDefaultRoutePlanner} with
+ * {@link ProxySelector#getDefault()}, which uses the proxy settings from <a
+ * href="http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html">system
+ * properties</a>.</li>
+ * </ul>
+ *
+ * @return new instance of the Apache HTTP client
+ * @since 1.31
+ */
+ public static HttpClientBuilder newDefaultHttpClientBuilder() {
// Set socket buffer sizes to 8192
SocketConfig socketConfig =
SocketConfig.custom()
@@ -144,8 +169,7 @@ public final class ApacheHttpTransport extends HttpTransport {
.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
.setConnectionManager(connectionManager)
.disableRedirectHandling()
- .disableAutomaticRetries()
- .build();
+ .disableAutomaticRetries();
}
@Override
