Top Description Constructors Methods
org.springframework.web.cors.reactive

public abstract Class CorsUtils

extends Object
Class Inheritance
Imports
java.net.URI, org.springframework.http.HttpHeaders, .HttpMethod, org.springframework.http.server.reactive.ServerHttpRequest, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.util.UriComponents, .UriComponentsBuilder

Utility class for CORS reactive request handling based on the CORS W3C recommendation.
Author
Sebastien Deleuze
Since
5.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static int
getPort(String scheme, int port)

public static boolean
isCorsRequest(ServerHttpRequest request)

Returns true if the request is a valid CORS one by checking Origin header presence and ensuring that origins are different via isSameOrigin.

public static boolean
isPreFlightRequest(ServerHttpRequest request)

Returns true if the request is a valid CORS pre-flight one by checking OPTIONS method with Origin and Access-Control-Request-Method headers presence.

public static boolean

Returns:

true if the request is a same-origin one, false in case of a cross-origin request
isSameOrigin
(ServerHttpRequest request)

Deprecated as of 5.2, same-origin checks are performed directly by isCorsRequest
Check if the request is a same-origin one, based on Origin, and Host headers.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CorsUtilsback to summary
public CorsUtils()

Method Detail

getPortback to summary
private static int getPort(String scheme, int port)
isCorsRequestback to summary
public static boolean isCorsRequest(ServerHttpRequest request)

Returns true if the request is a valid CORS one by checking Origin header presence and ensuring that origins are different via isSameOrigin.

Annotations
@SuppressWarnings:deprecation
isPreFlightRequestback to summary
public static boolean isPreFlightRequest(ServerHttpRequest request)

Returns true if the request is a valid CORS pre-flight one by checking OPTIONS method with Origin and Access-Control-Request-Method headers presence.

isSameOriginback to summary
public static boolean isSameOrigin(ServerHttpRequest request)

Deprecated

as of 5.2, same-origin checks are performed directly by isCorsRequest

Check if the request is a same-origin one, based on Origin, and Host headers.

Note

as of 5.1 this method ignores "Forwarded" and "X-Forwarded-*" headers that specify the client-originated address. Consider using the ForwardedHeaderFilter to extract and use, or to discard such headers.

Returns:boolean

true if the request is a same-origin one, false in case of a cross-origin request

Annotations
@Deprecated