CorsConfig { public HttpHeaders preflightResponseHeaders() { if (preflightHeaders.isEmpty()) { return EmptyHttpHeaders.INSTANCE; } final HttpHeaders preflightHeaders = new DefaultHttpHeaders(); for (Entry<CharSequence, Callable<?>> entry : this.preflightHeaders.entrySet()) { final Object value = getValue(entry.getValue()); if (value instanceof Iterable) { preflightHeaders.add(entry.getKey(), (Iterable<?>) value); } else { preflightHeaders.add(entry.getKey(), value); } } return preflightHeaders; } CorsConfig(final CorsConfigBuilder builder); boolean isCorsSupportEnabled(); boolean isAnyOriginSupported(); String origin(); Set<String> origins(); boolean isNullOriginAllowed(); Set<String> exposedHeaders(); boolean isCredentialsAllowed(); long maxAge(); Set<HttpMethod> allowedRequestMethods(); Set<String> allowedRequestHeaders(); HttpHeaders preflightResponseHeaders(); boolean isShortCircuit(); @Deprecated boolean isShortCurcuit(); @Override String toString(); @Deprecated static Builder withAnyOrigin(); @Deprecated static Builder withOrigin(final String origin); @Deprecated static Builder withOrigins(final String... origins);  }
@Test public void preflightResponseHeadersSingleValue() { final CorsConfig cors = forAnyOrigin().preflightResponseHeader("SingleValue", "value").build(); assertThat(cors.preflightResponseHeaders().get(of("SingleValue")), equalTo("value")); }
@Test public void preflightResponseHeadersMultipleValues() { final CorsConfig cors = forAnyOrigin().preflightResponseHeader("MultipleValues", "value1", "value2").build(); assertThat(cors.preflightResponseHeaders().getAll(of("MultipleValues")), hasItems("value1", "value2")); }
@Test public void defaultPreflightResponseHeaders() { final CorsConfig cors = forAnyOrigin().build(); assertThat(cors.preflightResponseHeaders().get(HttpHeaderNames.DATE), is(notNullValue())); assertThat(cors.preflightResponseHeaders().get(HttpHeaderNames.CONTENT_LENGTH), is("0")); }
@Test public void emptyPreflightResponseHeaders() { final CorsConfig cors = forAnyOrigin().noPreflightResponseHeaders().build(); assertThat(cors.preflightResponseHeaders(), equalTo((HttpHeaders) EmptyHttpHeaders.INSTANCE)); }