Support explicitly setting forward headers strategy to NONE
Prior to this commit, there was no distinction between explicitly setting forward headers strategy to a value of NONE and not setting it at all. This meant that in a cloud environment, a cloud provider was always checked to see if it was active and using forward headers and there was no way to prevent that. This commit changes the default value of the property to null so that there is a way to determine if the property was explicitly set to NONE. Fixes gh-19333
This commit is contained in:
@@ -84,7 +84,7 @@ public class ServerProperties {
|
||||
/**
|
||||
* Strategy for handling X-Forwarded-* headers.
|
||||
*/
|
||||
private ForwardHeadersStrategy forwardHeadersStrategy = ForwardHeadersStrategy.NONE;
|
||||
private ForwardHeadersStrategy forwardHeadersStrategy;
|
||||
|
||||
/**
|
||||
* Value to use for the Server response header (if empty, no header is sent).
|
||||
|
||||
@@ -102,7 +102,7 @@ public class JettyWebServerFactoryCustomizer
|
||||
}
|
||||
|
||||
private boolean getOrDeduceUseForwardHeaders() {
|
||||
if (this.serverProperties.getForwardHeadersStrategy().equals(ServerProperties.ForwardHeadersStrategy.NONE)) {
|
||||
if (this.serverProperties.getForwardHeadersStrategy() == null) {
|
||||
CloudPlatform platform = CloudPlatform.getActive(this.environment);
|
||||
return platform != null && platform.isUsingForwardHeaders();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class NettyWebServerFactoryCustomizer
|
||||
}
|
||||
|
||||
private boolean getOrDeduceUseForwardHeaders() {
|
||||
if (this.serverProperties.getForwardHeadersStrategy().equals(ServerProperties.ForwardHeadersStrategy.NONE)) {
|
||||
if (this.serverProperties.getForwardHeadersStrategy() == null) {
|
||||
CloudPlatform platform = CloudPlatform.getActive(this.environment);
|
||||
return platform != null && platform.isUsingForwardHeaders();
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class TomcatWebServerFactoryCustomizer
|
||||
}
|
||||
|
||||
private boolean getOrDeduceUseForwardHeaders() {
|
||||
if (this.serverProperties.getForwardHeadersStrategy().equals(ServerProperties.ForwardHeadersStrategy.NONE)) {
|
||||
if (this.serverProperties.getForwardHeadersStrategy() == null) {
|
||||
CloudPlatform platform = CloudPlatform.getActive(this.environment);
|
||||
return platform != null && platform.isUsingForwardHeaders();
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class UndertowWebServerFactoryCustomizer
|
||||
}
|
||||
|
||||
private boolean getOrDeduceUseForwardHeaders() {
|
||||
if (this.serverProperties.getForwardHeadersStrategy().equals(ServerProperties.ForwardHeadersStrategy.NONE)) {
|
||||
if (this.serverProperties.getForwardHeadersStrategy() == null) {
|
||||
CloudPlatform platform = CloudPlatform.getActive(this.environment);
|
||||
return platform != null && platform.isUsingForwardHeaders();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user