Commit f094ecfd by Dave Syer

Allow user to set system properties to control http client in zuul

The SimpleHostRoutingFilter now accepts normal -Dhttps.proxy= and -Dhttps.port= settings (and other things that generally work with java.net). Fixes gh-510
parent 13268f7c
......@@ -181,8 +181,7 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
setResponse(response);
}
catch (Exception ex) {
context.set(ERROR_STATUS_CODE,
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
context.set(ERROR_STATUS_CODE, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
context.set("error.exception", ex);
}
return null;
......@@ -211,7 +210,7 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder
.<ConnectionSocketFactory> create()
.register("http", PlainConnectionSocketFactory.INSTANCE);
if (sslHostnameValidationEnabled) {
if (this.sslHostnameValidationEnabled) {
registryBuilder.register("https",
new SSLConnectionSocketFactory(sslContext));
}
......@@ -240,11 +239,11 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
HttpClientBuilder httpClientBuilder = HttpClients.custom();
if (!sslHostnameValidationEnabled) {
if (!this.sslHostnameValidationEnabled) {
httpClientBuilder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
}
return httpClientBuilder.setConnectionManager(newConnectionManager())
.setDefaultRequestConfig(requestConfig)
.useSystemProperties().setDefaultRequestConfig(requestConfig)
.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false))
.setRedirectStrategy(new RedirectStrategy() {
@Override
......@@ -380,9 +379,9 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
/**
* Determines whether the filter enables the validation for ssl hostnames.
* @return
* @return true if enabled
*/
boolean isSslHostnameValidationEnabled() {
return sslHostnameValidationEnabled;
return this.sslHostnameValidationEnabled;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment