Package org.springframework.web.cors.reactive

# Class DefaultCorsProcessor

java.lang.Object
org.springframework.web.cors.reactive.DefaultCorsProcessor

All Implemented Interfaces:
  `CorsProcessor`

public class DefaultCorsProcessor extends Object implements CorsProcessor
The default implementation of `CorsProcessor`, as defined by the CORS W3C recommendation.

Note that when the supplied `CorsConfiguration` is `null`, this implementation does not reject simple or actual requests outright but simply avoids adding CORS headers to the response. CORS processing is also skipped if the response already contains CORS headers.

Since:
  5.0
Author:
  Sebastien Deleuze, Rossen Stoyanchev

## Constructor Summary

Constructors
Constructor
Description
`DefaultCorsProcessor()`

## Method Summary

Modifier and Type
Method
Description
`protected List<String>`
`checkHeaders(CorsConfiguration config, List<String> requestHeaders)`
Check the headers and determine the headers for the response of a pre-flight request.
`protected List<HttpMethod>`
`checkMethods(CorsConfiguration config, HttpMethod requestMethod)`
Check the HTTP method and determine the methods for the response of a pre-flight request.
`protected String`
`checkOrigin(CorsConfiguration config, String requestOrigin)`
Check the origin and determine the origin for the response.
`protected boolean`
`handleInternal(ServerWebExchange exchange, CorsConfiguration config, boolean preFlightRequest)`
Handle the given request.
`boolean`
`process(CorsConfiguration config, ServerWebExchange exchange)`
Process a request using the given `CorsConfiguration`.
`protected void`
`rejectRequest(ServerHttpResponse response)`
Invoked when one of the CORS checks failed.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefaultCorsProcessor

public DefaultCorsProcessor()

## Method Details

### process

public boolean process(@Nullable CorsConfiguration config, ServerWebExchange exchange)
Description copied from interface: `CorsProcessor`
Process a request using the given `CorsConfiguration`.

Specified by:
  `process` in interface `CorsProcessor`
Parameters:
  `config` - the CORS configuration to use; possibly `null` in which case pre-flight requests are rejected, but all others allowed.
  `exchange` - the current exchange
Returns:
  `false` if the request was rejected, `true` otherwise

### rejectRequest

protected void rejectRequest(ServerHttpResponse response)
Invoked when one of the CORS checks failed.

### handleInternal

protected boolean handleInternal(ServerWebExchange exchange, CorsConfiguration config, boolean preFlightRequest)
Handle the given request.

### checkOrigin

@Nullable protected String checkOrigin(CorsConfiguration config, @Nullable String requestOrigin)
Check the origin and determine the origin for the response. The default implementation simply delegates to `CorsConfiguration.checkOrigin(String)`.

### checkMethods

@Nullable protected List<HttpMethod> checkMethods(CorsConfiguration config, @Nullable HttpMethod requestMethod)
Check the HTTP method and determine the methods for the response of a pre-flight request. The default implementation simply delegates to `CorsConfiguration.checkHttpMethod(HttpMethod)`.

### checkHeaders

@Nullable protected List<String> checkHeaders(CorsConfiguration config, List<String> requestHeaders)
Check the headers and determine the headers for the response of a pre-flight request. The default implementation simply delegates to `CorsConfiguration.checkHeaders(List)`.