Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/bugfix-Apache5HTTPClient-6c80c24.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "Apache 5 HTTP Client",
"contributor": "",
"description": "Trimmed surrounding whitespace from `nonProxyHosts` / `no_proxy` entries so comma- or pipe-separated values with spaces (e.g. `no_proxy=a.com, *.foo.com`) are honored. Previously an entry with a leading or trailing space was treated as part of the host name and never matched, so the host was routed through the proxy instead of bypassing it."
}
6 changes: 6 additions & 0 deletions .changes/next-release/bugfix-ApacheHTTPClient-97e1afc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "Apache HTTP Client",
"contributor": "",
"description": "Trimmed surrounding whitespace from `nonProxyHosts` / `no_proxy` entries so comma- or pipe-separated values with spaces (e.g. `no_proxy=a.com, *.foo.com`) are honored. Previously an entry with a leading or trailing space was treated as part of the host name and never matched, so the host was routed through the proxy instead of bypassing it."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "Netty NIO HTTP Client",
"contributor": "",
"description": "Trimmed surrounding whitespace from `nonProxyHosts` / `no_proxy` entries so comma- or pipe-separated values with spaces (e.g. `no_proxy=a.com, *.foo.com`) are honored. Previously an entry with a leading or trailing space was treated as part of the host name and never matched, so the host was routed through the proxy instead of bypassing it."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "URL Connection HTTP Client",
"contributor": "",
"description": "Trimmed surrounding whitespace from `nonProxyHosts` / `no_proxy` entries so comma- or pipe-separated values with spaces (e.g. `no_proxy=a.com, *.foo.com`) are honored. Previously an entry with a leading or trailing space was treated as part of the host name and never matched, so the host was routed through the proxy instead of bypassing it."
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ public interface Builder {
* are not provided during building the {@link CrtProxyConfiguration} object. To disable this behaviour, set this value to
* false.It is important to note that when this property is set to "true," all proxy settings will exclusively originate
* from system properties, and no partial settings will be obtained from EnvironmentVariableValues.
* <p>Pipe-separated host names in the {@code http.nonProxyHosts} system property indicate multiple hosts to exclude
* from proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com|b.com"} and
* {@code "a.com | b.com"} are accepted.
*
* @param useSystemPropertyValues The option whether to use system property values
* @return This object for method chaining.
Expand All @@ -272,7 +275,8 @@ public interface Builder {
* value to false.It is important to note that when this property is set to "true," all proxy settings will exclusively
* originate from environment variableValues, and no partial settings will be obtained from SystemPropertyValues.
* <p>Comma-separated host names in the NO_PROXY environment variable indicate multiple hosts to exclude from
* proxy settings.
* proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com,b.com"} and
* {@code "a.com, b.com"} are accepted.
*
* @param useEnvironmentVariableValues The option whether to use environment variable values
* @return This object for method chaining.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,18 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {

/**
* Configure the hosts that the client is allowed to access without going through the proxy.
* <p>Entries supplied here are treated as exact host names (e.g. {@code example.com}) or CIDR ranges for IP addresses
* (e.g. {@code 10.0.0.0/8}). Wildcard patterns such as {@code *.example.com} or a bare {@code *} are not supported for
* entries supplied here; to use wildcards, configure them through the {@code http.nonProxyHosts} system property or the
* {@code NO_PROXY} environment variable instead.
*/
Builder nonProxyHosts(Set<String> nonProxyHosts);

/**
* Add a host that the client is allowed to access without going through the proxy.
* <p>The host is treated as an exact host name or CIDR range; wildcard patterns are not supported for entries supplied
* here. See {@link #nonProxyHosts(Set)} for details on wildcard support through the system property or environment
* variable.
*
* @see ProxyConfiguration#nonProxyHosts()
*/
Expand All @@ -281,6 +288,11 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* are not provided during building the {@link ProxyConfiguration} object. To disable this behavior, set this value to
* "false".It is important to note that when this property is set to "true," all proxy settings will exclusively originate
* from system properties, and no partial settings will be obtained from EnvironmentVariableValues.
* <p>Pipe-separated host names in the {@code http.nonProxyHosts} system property indicate multiple hosts to exclude
* from proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com|b.com"} and
* {@code "a.com | b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*/
Builder useSystemPropertyValues(Boolean useSystemPropertyValues);

Expand All @@ -293,7 +305,10 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* proxy settings will exclusively originate from environment variableValues, and no partial settings will be obtained
* from SystemPropertyValues.
* <p>Comma-separated host names in the NO_PROXY environment variable indicate multiple hosts to exclude from
* proxy settings.
* proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com,b.com"} and
* {@code "a.com, b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*
* @param useEnvironmentVariableValues The option whether to use environment variable values.
* @return This object for method chaining.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,18 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {

/**
* Configure the hosts that the client is allowed to access without going through the proxy.
* <p>Entries supplied here are treated as exact host names (e.g. {@code example.com}) or CIDR ranges for IP addresses
* (e.g. {@code 10.0.0.0/8}). Wildcard patterns such as {@code *.example.com} or a bare {@code *} are not supported for
* entries supplied here; to use wildcards, configure them through the {@code http.nonProxyHosts} system property or the
* {@code NO_PROXY} environment variable instead.
*/
Builder nonProxyHosts(Set<String> nonProxyHosts);

/**
* Add a host that the client is allowed to access without going through the proxy.
* <p>The host is treated as an exact host name or CIDR range; wildcard patterns are not supported for entries supplied
* here. See {@link #nonProxyHosts(Set)} for details on wildcard support through the system property or environment
* variable.
*
* @see ProxyConfiguration#nonProxyHosts()
*/
Expand All @@ -281,6 +288,11 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* are not provided during building the {@link ProxyConfiguration} object. To disable this behavior, set this value to
* "false".It is important to note that when this property is set to "true," all proxy settings will exclusively originate
* from system properties, and no partial settings will be obtained from EnvironmentVariableValues.
* <p>Pipe-separated host names in the {@code http.nonProxyHosts} system property indicate multiple hosts to exclude
* from proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com|b.com"} and
* {@code "a.com | b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*/
Builder useSystemPropertyValues(Boolean useSystemPropertyValues);

Expand All @@ -293,7 +305,10 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* proxy settings will exclusively originate from environment variableValues, and no partial settings will be obtained
* from SystemPropertyValues.
* <p>Comma-separated host names in the NO_PROXY environment variable indicate multiple hosts to exclude from
* proxy settings.
* proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com,b.com"} and
* {@code "a.com, b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*
* @param useEnvironmentVariableValues The option whether to use environment variable values.
* @return This object for method chaining.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,12 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
Builder scheme(String scheme);

/**
* Set the set of hosts that should not be proxied. Any request whose host portion matches any of the patterns
* given in the set will be sent to the remote host directly instead of through the proxy.
* Set the set of hosts that should not be proxied. Any request whose host portion matches one of these entries will be
* sent to the remote host directly instead of through the proxy.
* <p>Entries supplied here are treated as exact host names (e.g. {@code example.com}) or CIDR ranges for IP addresses
* (e.g. {@code 10.0.0.0/8}). Wildcard patterns such as {@code *.example.com} or a bare {@code *} are not supported for
* entries supplied here; to use wildcards, configure them through the {@code http.nonProxyHosts} system property or the
* {@code NO_PROXY} environment variable instead.
*
* @param nonProxyHosts The set of hosts that should not be proxied.
* @return This object for method chaining.
Expand Down Expand Up @@ -265,6 +269,11 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* options are not provided during building the {@link ProxyConfiguration} object. To disable this behaviour, set this
* value to false.It is important to note that when this property is set to "true," all proxy settings will exclusively
* be obtained from System Property Values, and no partial settings will be obtained from Environment Variable Values.
* <p>Pipe-separated host names in the {@code http.nonProxyHosts} system property indicate multiple hosts to exclude
* from proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com|b.com"} and
* {@code "a.com | b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*
* @param useSystemPropertyValues The option whether to use system property values
* @return This object for method chaining.
Expand All @@ -280,7 +289,10 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* proxy settings will exclusively originate from Environment Variable Values, and no partial settings will be obtained
* from System Property Values.
* <p>Comma-separated host names in the NO_PROXY environment variable indicate multiple hosts to exclude from
* proxy settings.
* proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com,b.com"} and
* {@code "a.com, b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*
* @param useEnvironmentVariablesValues The option whether to use environment variable values
* @return This object for method chaining.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
import software.amazon.awssdk.http.async.AsyncExecuteRequest;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
import software.amazon.awssdk.http.async.SdkAsyncHttpResponseHandler;
import software.amazon.awssdk.testutils.EnvironmentVariableHelper;

/**
* Tests for HTTP proxy functionality in the Netty client.
*/
public class ProxyWireMockTest {
private static final EnvironmentVariableHelper ENVIRONMENT_VARIABLE_HELPER = new EnvironmentVariableHelper();

private static SdkAsyncHttpClient client;

private static ProxyConfiguration proxyCfg;
Expand Down Expand Up @@ -79,6 +82,7 @@ public void methodTeardown() {
client.close();
}
client = null;
ENVIRONMENT_VARIABLE_HELPER.reset();
}

@Test(expected = IOException.class)
Expand Down Expand Up @@ -150,6 +154,32 @@ public void proxyConfigured_hostInNonProxySet_nonBlockingDns_doesNotConnect() {
assertThat(responseHandler.fullResponseAsString()).isEqualTo("hello");
}

@Test
public void proxyConfigured_hostInCommaSpaceNoProxyEnv_doesNotConnect() {
ENVIRONMENT_VARIABLE_HELPER.set("no_proxy", "example.com, localhost");

RecordingResponseHandler responseHandler = new RecordingResponseHandler();
AsyncExecuteRequest req = AsyncExecuteRequest.builder()
.request(testSdkRequest())
.responseHandler(responseHandler)
.requestContentPublisher(new EmptyPublisher())
.build();

ProxyConfiguration cfg = ProxyConfiguration.builder()
.host("localhost")
.port(mockProxy.port())
.build();

client = NettyNioAsyncHttpClient.builder()
.proxyConfiguration(cfg)
.build();

client.execute(req).join();

responseHandler.completeFuture.join();
assertThat(responseHandler.fullResponseAsString()).isEqualTo("hello");
}

private SdkHttpFullRequest testSdkRequest() {
return SdkHttpFullRequest.builder()
.method(SdkHttpMethod.GET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,18 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {

/**
* Configure the hosts that the client is allowed to access without going through the proxy.
* <p>Entries supplied here are treated as exact host names (e.g. {@code example.com}) or CIDR ranges for IP addresses
* (e.g. {@code 10.0.0.0/8}). Wildcard patterns such as {@code *.example.com} or a bare {@code *} are not supported for
* entries supplied here; to use wildcards, configure them through the {@code http.nonProxyHosts} system property or the
* {@code NO_PROXY} environment variable instead.
*/
Builder nonProxyHosts(Set<String> nonProxyHosts);

/**
* Add a host that the client is allowed to access without going through the proxy.
* <p>The host is treated as an exact host name or CIDR range; wildcard patterns are not supported for entries supplied
* here. See {@link #nonProxyHosts(Set)} for details on wildcard support through the system property or environment
* variable.
*
* @see ProxyConfiguration#nonProxyHosts()
*/
Expand All @@ -236,6 +243,11 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* are not provided during building the {@link ProxyConfiguration} object. To disable this behavior, set this value to
* "false".It is important to note that when this property is set to "true," all proxy settings will exclusively originate
* from system properties, and no partial settings will be obtained from EnvironmentVariableValues
* <p>Pipe-separated host names in the {@code http.nonProxyHosts} system property indicate multiple hosts to exclude
* from proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com|b.com"} and
* {@code "a.com | b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*/
Builder useSystemPropertyValues(Boolean useSystemPropertyValues);

Expand All @@ -246,7 +258,10 @@ public interface Builder extends CopyableBuilder<Builder, ProxyConfiguration> {
* value to "false".It is important to note that when this property is set to "true," all proxy settings will exclusively
* originate from environment variableValues, and no partial settings will be obtained from SystemPropertyValues.
* <p>Comma-separated host names in the NO_PROXY environment variable indicate multiple hosts to exclude from
* proxy settings.
* proxy settings. Surrounding empty spaces around each host name are trimmed, so both {@code "a.com,b.com"} and
* {@code "a.com, b.com"} are accepted. Each entry may be an exact host name (e.g. {@code example.com}), a
* leading-wildcard suffix (e.g. {@code *.example.com}, which matches {@code example.com} and its subdomains),
* a single {@code *} (which matches all hosts), or a CIDR range for IP addresses (e.g. {@code 10.0.0.0/8}).
*
* @param useEnvironmentVariablesValues The option whether to use environment variable values
* @return This object for method chaining.
Expand Down
Loading
Loading