Top Description Constructors Methods
org.springframework.web.cors

public abstract Class CorsUtils

extends Object
Class Inheritance
Imports
jakarta.servlet.http.HttpServletRequest, org.springframework.http.HttpHeaders, .HttpMethod, org.springframework.lang.Nullable, org.springframework.util.ObjectUtils, org.springframework.web.util.UriComponents, .UriComponentsBuilder

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

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(HttpServletRequest request)

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

public static boolean
isPreFlightRequest(HttpServletRequest 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.

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(HttpServletRequest request)

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

isPreFlightRequestback to summary
public static boolean isPreFlightRequest(HttpServletRequest 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.