33
33
import org .apache .http .client .methods .HttpPost ;
34
34
import org .apache .http .client .methods .HttpUriRequest ;
35
35
import org .apache .http .entity .ByteArrayEntity ;
36
+ import org .apache .http .impl .client .CloseableHttpClient ;
36
37
import org .apache .http .protocol .BasicHttpContext ;
37
38
import org .apache .http .protocol .HttpContext ;
38
39
import org .apache .http .util .EntityUtils ;
46
47
import java .net .URI ;
47
48
import java .net .URISyntaxException ;
48
49
import java .net .URL ;
49
- import java .util .concurrent .TimeUnit ;
50
50
51
51
public class ApacheHttpClient implements org .openqa .selenium .remote .http .HttpClient {
52
52
53
53
private static final int MAX_REDIRECTS = 10 ;
54
54
55
55
private final URL url ;
56
56
private final HttpHost targetHost ;
57
- private final HttpClient client ;
57
+ private final CloseableHttpClient client ;
58
58
59
- public ApacheHttpClient (HttpClient client , URL url ) {
59
+ public ApacheHttpClient (CloseableHttpClient client , URL url ) {
60
60
this .client = checkNotNull (client , "null HttpClient" );
61
61
this .url = checkNotNull (url , "null URL" );
62
62
@@ -234,7 +234,7 @@ public Factory(HttpClientFactory clientFactory) {
234
234
@ Override
235
235
public org .openqa .selenium .remote .http .HttpClient createClient (URL url ) {
236
236
checkNotNull (url , "null URL" );
237
- HttpClient client ;
237
+ CloseableHttpClient client ;
238
238
if (url .getUserInfo () != null ) {
239
239
UsernamePasswordCredentials credentials =
240
240
new UsernamePasswordCredentials (url .getUserInfo ());
@@ -252,10 +252,10 @@ private static synchronized HttpClientFactory getDefaultHttpClientFactory() {
252
252
return defaultClientFactory ;
253
253
}
254
254
}
255
-
255
+
256
256
@ Override
257
257
public void close () throws IOException {
258
- client .getConnectionManager (). closeIdleConnections ( 0 , TimeUnit . SECONDS );
258
+ client .close ();
259
259
}
260
-
260
+
261
261
}
0 commit comments