1818import com .google .api .client .http .HttpBackOffIOExceptionHandler ;
1919import com .google .api .client .http .HttpRequestFactory ;
2020import com .google .api .client .http .HttpTransport ;
21- import com .google .api .client .http .apache .v2 . ApacheHttpTransport ;
21+ import com .google .api .client .http .apache .v5 . Apache5HttpTransport ;
2222import com .google .api .client .util .ExponentialBackOff ;
2323import com .google .api .client .util .ObjectParser ;
2424import dev .sigstore .forbidden .SuppressForbidden ;
2525import javax .annotation .Nullable ;
26- import org .apache .http .HttpHeaders ;
27- import org .apache .http .conn .ssl .NoopHostnameVerifier ;
28- import org .apache .http .impl .client .HttpClientBuilder ;
26+ import org .apache .hc .client5 .http .config .ConnectionConfig ;
27+ import org .apache .hc .client5 .http .impl .io .PoolingHttpClientConnectionManagerBuilder ;
28+ import org .apache .hc .client5 .http .ssl .NoopHostnameVerifier ;
29+ import org .apache .hc .client5 .http .ssl .SSLConnectionSocketFactoryBuilder ;
30+ import org .apache .hc .core5 .http .HttpHeaders ;
31+ import org .apache .hc .core5 .util .TimeValue ;
2932
3033/** HttpClients generates Google Http Client objects from configuration. */
3134public class HttpClients {
@@ -36,11 +39,24 @@ public class HttpClients {
3639 * you need to also configure the response parser}.
3740 */
3841 public static HttpTransport newHttpTransport (HttpParams httpParams ) {
39- HttpClientBuilder hcb = ApacheHttpTransport .newDefaultHttpClientBuilder ();
4042 if (httpParams .getAllowInsecureConnections ()) {
41- hcb .setSSLHostnameVerifier (NoopHostnameVerifier .INSTANCE );
43+ var connManager =
44+ PoolingHttpClientConnectionManagerBuilder .create ()
45+ .setSSLSocketFactory (
46+ SSLConnectionSocketFactoryBuilder .create ()
47+ .setHostnameVerifier (NoopHostnameVerifier .INSTANCE )
48+ .build ())
49+ .setMaxConnTotal (200 )
50+ .setMaxConnPerRoute (20 )
51+ .setDefaultConnectionConfig (
52+ ConnectionConfig .custom ().setTimeToLive (TimeValue .NEG_ONE_MILLISECOND ).build ())
53+ .build ();
54+ return new Apache5HttpTransport (
55+ Apache5HttpTransport .newDefaultHttpClientBuilder ()
56+ .setConnectionManager (connManager )
57+ .build ());
4258 }
43- return new ApacheHttpTransport ( hcb .build ());
59+ return new Apache5HttpTransport ( Apache5HttpTransport . newDefaultHttpClientBuilder () .build ());
4460 }
4561
4662 /** Create a new get requests with the httpParams applied and retries. */
0 commit comments