@Filter(value="/**") public class CorsFilter extends Object implements HttpServerFilter
Modifier and Type | Field and Description |
---|---|
protected HttpServerConfiguration.CorsConfiguration |
corsConfiguration |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
CorsFilter(HttpServerConfiguration.CorsConfiguration corsConfiguration)
Deprecated.
|
CorsFilter(HttpServerConfiguration.CorsConfiguration corsConfiguration,
HttpHostResolver httpHostResolver) |
Modifier and Type | Method and Description |
---|---|
Publisher<MutableHttpResponse<?>> |
doFilter(HttpRequest<?> request,
ServerFilterChain chain)
Variation of the
HttpServerFilter.doFilter(HttpRequest, FilterChain) method that accepts a ServerFilterChain
which allows to mutate the outgoing HTTP response. |
int |
getOrder() |
protected Optional<MutableHttpResponse<?>> |
handleRequest(HttpRequest request)
Deprecated.
Not used any more.
|
protected void |
handleResponse(HttpRequest<?> request,
MutableHttpResponse<?> response)
Deprecated.
not used
|
protected void |
setAllowCredentials(CorsOriginConfiguration config,
MutableHttpResponse<?> response) |
protected void |
setAllowHeaders(List<?> optionalAllowHeaders,
MutableHttpResponse<?> response) |
protected void |
setAllowMethods(HttpMethod method,
MutableHttpResponse<?> response) |
protected void |
setExposeHeaders(List<String> exposedHeaders,
MutableHttpResponse<?> response) |
protected void |
setMaxAge(long maxAge,
MutableHttpResponse<?> response) |
protected void |
setOrigin(String origin,
MutableHttpResponse<?> response) |
protected void |
setVary(MutableHttpResponse<?> response) |
protected boolean |
shouldDenyToPreventDriveByLocalhostAttack(CorsOriginConfiguration corsOriginConfiguration,
HttpRequest<?> request) |
protected boolean |
shouldDenyToPreventDriveByLocalhostAttack(String origin,
HttpRequest<?> request) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
doFilter
protected final HttpServerConfiguration.CorsConfiguration corsConfiguration
@Inject public CorsFilter(HttpServerConfiguration.CorsConfiguration corsConfiguration, @Nullable HttpHostResolver httpHostResolver)
corsConfiguration
- The CorsOriginConfiguration
instancehttpHostResolver
- HTTP Host resolver@Deprecated public CorsFilter(HttpServerConfiguration.CorsConfiguration corsConfiguration)
CorsFilter(HttpServerConfiguration.CorsConfiguration, HttpHostResolver)
instead.corsConfiguration
- The CorsOriginConfiguration
instancepublic Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain)
HttpServerFilter
HttpServerFilter.doFilter(HttpRequest, FilterChain)
method that accepts a ServerFilterChain
which allows to mutate the outgoing HTTP response.doFilter
in interface HttpServerFilter
request
- The requestchain
- The chainPublisher
that emits a MutableHttpResponse
HttpServerFilter.doFilter(HttpRequest, FilterChain)
protected boolean shouldDenyToPreventDriveByLocalhostAttack(@NonNull CorsOriginConfiguration corsOriginConfiguration, @NonNull HttpRequest<?> request)
corsOriginConfiguration
- CORS Origin configuration for request's HTTP Header origin.request
- HTTP Requestprotected boolean shouldDenyToPreventDriveByLocalhostAttack(@NonNull String origin, @NonNull HttpRequest<?> request)
origin
- HTTP Header HttpHeaders.ORIGIN
value.request
- HTTP Requestpublic int getOrder()
@Deprecated protected void handleResponse(HttpRequest<?> request, MutableHttpResponse<?> response)
request
- The HttpRequest
objectresponse
- The MutableHttpResponse
object@Deprecated protected Optional<MutableHttpResponse<?>> handleRequest(HttpRequest request)
HttpRequest
.request
- The HttpRequest
objectMutableHttpResponse
. The request should proceed normally if emptyprotected void setAllowCredentials(CorsOriginConfiguration config, MutableHttpResponse<?> response)
config
- The CorsOriginConfiguration
instanceresponse
- The MutableHttpResponse
objectprotected void setExposeHeaders(List<String> exposedHeaders, MutableHttpResponse<?> response)
exposedHeaders
- A list of the exposed headersresponse
- The MutableHttpResponse
objectprotected void setVary(MutableHttpResponse<?> response)
response
- The MutableHttpResponse
objectprotected void setOrigin(@Nullable String origin, @NonNull MutableHttpResponse<?> response)
origin
- The originresponse
- The MutableHttpResponse
objectprotected void setAllowMethods(HttpMethod method, MutableHttpResponse<?> response)
method
- The HttpMethod
objectresponse
- The MutableHttpResponse
objectprotected void setAllowHeaders(List<?> optionalAllowHeaders, MutableHttpResponse<?> response)
optionalAllowHeaders
- A list with optional allow headersresponse
- The MutableHttpResponse
objectprotected void setMaxAge(long maxAge, MutableHttpResponse<?> response)
maxAge
- The max ageresponse
- The MutableHttpResponse
object