diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml
index b32f83da..2171a3b8 100644
--- a/maven-plugin-tools-api/pom.xml
+++ b/maven-plugin-tools-api/pom.xml
@@ -88,14 +88,9 @@
- org.apache.httpcomponents
- httpclient
- 4.5.14
-
-
- org.apache.httpcomponents
- httpcore
- 4.4.16
+ org.apache.httpcomponents.client5
+ httpclient5
+ 5.6
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java
index 36670126..a01c8840 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocSite.java
@@ -39,32 +39,33 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.regex.Pattern;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.message.BasicHeader;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.CredentialsStore;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.cookie.StandardCookieSpec;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.apache.maven.tools.plugin.javadoc.FullyQualifiedJavadocReference.MemberType;
@@ -472,10 +473,10 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
builder.setConnectionManager(new PoolingHttpClientConnectionManager(csfRegistry));
builder.setDefaultRequestConfig(RequestConfig.custom()
- .setSocketTimeout(DEFAULT_TIMEOUT)
- .setConnectTimeout(DEFAULT_TIMEOUT)
+ .setResponseTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
+ .setConnectTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
.setCircularRedirectsAllowed(true)
- .setCookieSpec(CookieSpecs.IGNORE_COOKIES)
+ .setCookieSpec(StandardCookieSpec.IGNORE)
.build());
// Some web servers don't allow the default user-agent sent by httpClient
@@ -496,11 +497,11 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
builder.setProxy(proxy);
if (StringUtils.isNotEmpty(activeProxy.getUsername()) && activeProxy.getPassword() != null) {
- Credentials credentials =
- new UsernamePasswordCredentials(activeProxy.getUsername(), activeProxy.getPassword());
+ Credentials credentials = new UsernamePasswordCredentials(
+ activeProxy.getUsername(), activeProxy.getPassword().toCharArray());
- CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
- credentialsProvider.setCredentials(AuthScope.ANY, credentials);
+ CredentialsStore credentialsProvider = new BasicCredentialsProvider();
+ credentialsProvider.setCredentials(new AuthScope(null, -1), credentials);
builder.setDefaultCredentialsProvider(credentialsProvider);
}
}
@@ -520,7 +521,7 @@ static BufferedReader getReader(URL url, Settings settings) throws IOException {
final HttpGet httpMethod = new HttpGet(url.toString());
- HttpResponse response;
+ ClassicHttpResponse response;
HttpClientContext httpContext = HttpClientContext.create();
try {
response = httpClient.execute(httpMethod, httpContext);
@@ -529,13 +530,13 @@ static BufferedReader getReader(URL url, Settings settings) throws IOException {
response = httpClient.execute(httpMethod, httpContext);
}
- int status = response.getStatusLine().getStatusCode();
+ int status = response.getCode();
if (status != HttpStatus.SC_OK) {
throw new FileNotFoundException(
"Unexpected HTTP status code " + status + " getting resource " + url.toExternalForm() + ".");
} else {
int pos = url.getPath().lastIndexOf('/');
- List redirects = httpContext.getRedirectLocations();
+ List redirects = httpContext.getRedirectLocations().getAll();
if (pos >= 0 && isNotEmpty(redirects)) {
URI location = redirects.get(redirects.size() - 1);
String suffix = url.getPath().substring(pos);
@@ -555,7 +556,7 @@ public void close() throws IOException {
super.close();
if (httpMethod != null) {
- httpMethod.releaseConnection();
+ httpMethod.reset();
}
if (httpClient != null) {
httpClient.close();