77
88import org .apache .hc .client5 .http .SystemDefaultDnsResolver ;
99import org .apache .hc .client5 .http .classic .methods .HttpUriRequestBase ;
10+ import org .apache .hc .client5 .http .config .ConnectionConfig ;
1011import org .apache .hc .client5 .http .config .RequestConfig ;
1112import org .apache .hc .client5 .http .impl .DefaultSchemePortResolver ;
1213import org .apache .hc .client5 .http .impl .classic .CloseableHttpClient ;
13- import org .apache .hc .client5 .http .impl .classic .CloseableHttpResponse ;
1414import org .apache .hc .client5 .http .impl .classic .HttpClients ;
1515import org .apache .hc .client5 .http .impl .io .DefaultHttpClientConnectionOperator ;
1616import org .apache .hc .client5 .http .impl .io .ManagedHttpClientConnectionFactory ;
1717import org .apache .hc .client5 .http .impl .io .PoolingHttpClientConnectionManager ;
1818import org .apache .hc .client5 .http .io .HttpClientConnectionOperator ;
1919import org .apache .hc .client5 .http .ssl .DefaultClientTlsStrategy ;
2020import org .apache .hc .client5 .http .ssl .TlsSocketStrategy ;
21+ import org .apache .hc .core5 .http .ClassicHttpResponse ;
2122import org .apache .hc .core5 .http .ConnectionClosedException ;
2223import org .apache .hc .core5 .http .ContentLengthStrategy ;
2324import org .apache .hc .core5 .http .Header ;
2425import org .apache .hc .core5 .http .HttpHeaders ;
2526import org .apache .hc .core5 .http .HttpHost ;
2627import org .apache .hc .core5 .http .NameValuePair ;
2728import org .apache .hc .core5 .http .impl .DefaultContentLengthStrategy ;
28- import org .apache .hc .core5 .http .impl .io .EmptyInputStream ;
2929import org .apache .hc .core5 .http .io .SocketConfig ;
3030import org .apache .hc .core5 .http .io .entity .ByteArrayEntity ;
31+ import org .apache .hc .core5 .http .io .entity .EmptyInputStream ;
3132import org .apache .hc .core5 .http .io .entity .InputStreamEntity ;
32- import org .apache .hc .core5 .http .protocol .BasicHttpContext ;
3333import org .apache .hc .core5 .http .protocol .HttpContext ;
34+ import org .apache .hc .core5 .http .protocol .HttpCoreContext ;
3435import org .apache .hc .core5 .net .URIAuthority ;
3536import org .apache .hc .core5 .util .TimeValue ;
3637import org .apache .hc .core5 .util .Timeout ;
@@ -119,13 +120,17 @@ protected ApacheDockerHttpClientImpl(
119120 .setSoTimeout (Timeout .ZERO_MILLISECONDS )
120121 .build ()
121122 );
122- connectionManager .setValidateAfterInactivity (TimeValue .NEG_ONE_SECOND );
123123 connectionManager .setMaxTotal (maxConnections );
124124 connectionManager .setDefaultMaxPerRoute (maxConnections );
125- RequestConfig .Builder defaultRequest = RequestConfig .custom ();
125+
126+ ConnectionConfig .Builder defaultConnection = ConnectionConfig .custom ();
127+ defaultConnection .setValidateAfterInactivity (TimeValue .NEG_ONE_SECOND );
126128 if (connectionTimeout != null ) {
127- defaultRequest .setConnectTimeout (connectionTimeout .toNanos (), TimeUnit .NANOSECONDS );
129+ defaultConnection .setConnectTimeout (connectionTimeout .toNanos (), TimeUnit .NANOSECONDS );
128130 }
131+ connectionManager .setDefaultConnectionConfig (defaultConnection .build ());
132+
133+ RequestConfig .Builder defaultRequest = RequestConfig .custom ();
129134 if (responseTimeout != null ) {
130135 defaultRequest .setResponseTimeout (responseTimeout .toNanos (), TimeUnit .NANOSECONDS );
131136 }
@@ -163,7 +168,7 @@ private HttpClientConnectionOperator createConnectionOperator(
163168
164169 @ Override
165170 public Response execute (Request request ) {
166- HttpContext context = new BasicHttpContext ();
171+ HttpContext context = new HttpCoreContext ();
167172 HttpUriRequestBase httpUriRequest = new HttpUriRequestBase (request .method (), URI .create (pathPrefix + request .path ()));
168173 httpUriRequest .setScheme (host .getSchemeName ());
169174 httpUriRequest .setAuthority (new URIAuthority (host .getHostName (), host .getPort ()));
@@ -187,7 +192,7 @@ public Response execute(Request request) {
187192 }
188193
189194 try {
190- CloseableHttpResponse response = httpClient .execute (host , httpUriRequest , context );
195+ ClassicHttpResponse response = httpClient .executeOpen (host , httpUriRequest , context );
191196
192197 return new ApacheResponse (httpUriRequest , response );
193198 } catch (IOException e ) {
@@ -206,9 +211,9 @@ static class ApacheResponse implements Response {
206211
207212 private final HttpUriRequestBase request ;
208213
209- private final CloseableHttpResponse response ;
214+ private final ClassicHttpResponse response ;
210215
211- ApacheResponse (HttpUriRequestBase httpUriRequest , CloseableHttpResponse response ) {
216+ ApacheResponse (HttpUriRequestBase httpUriRequest , ClassicHttpResponse response ) {
212217 this .request = httpUriRequest ;
213218 this .response = response ;
214219 }
0 commit comments