Skip to content

Commit

Permalink
NETWORK: Remove Dead Code from Netty4CorsConfig (elastic#34947)
Browse files Browse the repository at this point in the history
* Same as elastic#34324 for the Netty transport, the `isNullOriginAllowed` setting is always false
  • Loading branch information
original-brownbear authored Nov 5, 2018
1 parent 0fbb8a1 commit a95f057
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public final class Netty4CorsConfig {
private final long maxAge;
private final Set<HttpMethod> allowedRequestMethods;
private final Set<String> allowedRequestHeaders;
private final boolean allowNullOrigin;
private final Map<CharSequence, Callable<?>> preflightHeaders;
private final boolean shortCircuit;

Expand All @@ -61,7 +60,6 @@ public final class Netty4CorsConfig {
maxAge = builder.maxAge;
allowedRequestMethods = builder.requestMethods;
allowedRequestHeaders = builder.requestHeaders;
allowNullOrigin = builder.allowNullOrigin;
preflightHeaders = builder.preflightHeaders;
shortCircuit = builder.shortCircuit;
}
Expand Down Expand Up @@ -108,19 +106,6 @@ public boolean isOriginAllowed(final String origin) {
return false;
}

/**
* Web browsers may set the 'Origin' request header to 'null' if a resource is loaded
* from the local file system.
*
* If isNullOriginAllowed is true then the server will response with the wildcard for the
* the CORS response header 'Access-Control-Allow-Origin'.
*
* @return {@code true} if a 'null' origin should be supported.
*/
public boolean isNullOriginAllowed() {
return allowNullOrigin;
}

/**
* Determines if credentials are supported for CORS requests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public static Netty4CorsConfigBuilder forOrigins(final String... origins) {
Optional<Set<String>> origins;
Optional<Pattern> pattern;
final boolean anyOrigin;
boolean allowNullOrigin;
boolean enabled = true;
boolean allowCredentials;
long maxAge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ private void setPreflightHeaders(final HttpResponse response) {
private boolean setOrigin(final HttpResponse response) {
final String origin = request.headers().get(HttpHeaderNames.ORIGIN);
if (!Strings.isNullOrEmpty(origin)) {
if ("null".equals(origin) && config.isNullOriginAllowed()) {
setAnyOrigin(response);
return true;
}

if (config.isAnyOriginSupported()) {
if (config.isCredentialsAllowed()) {
echoRequestOrigin(response);
Expand Down Expand Up @@ -201,10 +196,6 @@ private boolean validateOrigin() {
return true;
}

if ("null".equals(origin) && config.isNullOriginAllowed()) {
return true;
}

// if the origin is the same as the host of the request, then allow
if (isSameOrigin(origin, request.headers().get(HttpHeaderNames.HOST))) {
return true;
Expand Down

0 comments on commit a95f057

Please sign in to comment.