You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/10/23 16:34:46 UTC
[httpcomponents-client] 04/08: Re-use core URIScheme instead of
String.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit bc7aae743ac7705f58af0ea9943ad464cb8e70d7
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Sun Oct 17 12:56:38 2021 +0200
Re-use core URIScheme instead of String.
---
.../hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java | 4 ++--
.../hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java | 3 ++-
.../http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java | 3 ++-
.../org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java | 3 ++-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
index 7e7e201..99add9f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
@@ -118,9 +118,9 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore {
// https.proxyUser/https.proxyPassword. We cannot simply use the protocol from
// the origin since a proxy retrieved from https.proxyHost/https.proxyPort will
// still use http as protocol
- systemcreds = getProxyCredentials("http", authScope);
+ systemcreds = getProxyCredentials(URIScheme.HTTP.getId(), authScope);
if (systemcreds == null) {
- systemcreds = getProxyCredentials("https", authScope);
+ systemcreds = getProxyCredentials(URIScheme.HTTPS.getId(), authScope);
}
}
if (systemcreds != null) {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
index d507154..3db4ca1 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
@@ -60,6 +60,7 @@ import org.apache.hc.core5.function.Resolver;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
@@ -128,7 +129,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
public PoolingAsyncClientConnectionManager() {
this(RegistryBuilder.<TlsStrategy>create()
- .register("https", DefaultClientTlsStrategy.getDefault())
+ .register(URIScheme.HTTPS.getId(), DefaultClientTlsStrategy.getDefault())
.build());
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
index 122e000..941f412 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
@@ -36,6 +36,7 @@ import org.apache.hc.client5.http.ssl.ConscryptClientTlsStrategy;
import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy;
import org.apache.hc.core5.function.Resolver;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
@@ -247,7 +248,7 @@ public class PoolingAsyncClientConnectionManagerBuilder {
}
final PoolingAsyncClientConnectionManager poolingmgr = new PoolingAsyncClientConnectionManager(
RegistryBuilder.<TlsStrategy>create()
- .register("https", tlsStrategyCopy)
+ .register(URIScheme.HTTPS.getId(), tlsStrategyCopy)
.build(),
poolConcurrencyPolicy,
poolReusePolicy,
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java
index f8b4621..fac55af 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java
@@ -41,6 +41,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@@ -75,7 +76,7 @@ public class DefaultRoutePlanner implements HttpRoutePlanner {
if (target.getPort() < 0) {
throw new ProtocolException("Unroutable protocol scheme: " + target);
}
- final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
+ final boolean secure = target.getSchemeName().equalsIgnoreCase(URIScheme.HTTPS.getId());
if (proxy == null) {
return new HttpRoute(target, determineLocalAddress(target, context), secure);
}