Example usage for org.springframework.web.cors.reactive CorsUtils isSameOrigin

List of usage examples for org.springframework.web.cors.reactive CorsUtils isSameOrigin

Introduction

In this page you can find the example usage for org.springframework.web.cors.reactive CorsUtils isSameOrigin.

Prototype

@Deprecated
public static boolean isSameOrigin(ServerHttpRequest request) 

Source Link

Document

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

Usage

From source file:org.springframework.web.cors.reactive.DefaultCorsProcessor.java

@Override
public boolean process(@Nullable CorsConfiguration config, ServerWebExchange exchange) {

    ServerHttpRequest request = exchange.getRequest();
    ServerHttpResponse response = exchange.getResponse();

    if (!CorsUtils.isCorsRequest(request)) {
        return true;
    }//from w  w  w .j av a 2s  .c om

    if (responseHasCors(response)) {
        logger.debug("Skip CORS: response already contains \"Access-Control-Allow-Origin\" header");
        return true;
    }

    if (CorsUtils.isSameOrigin(request)) {
        logger.debug("Skip CORS: request is from same origin");
        return true;
    }

    boolean preFlightRequest = CorsUtils.isPreFlightRequest(request);
    if (config == null) {
        if (preFlightRequest) {
            rejectRequest(response);
            return false;
        } else {
            return true;
        }
    }

    return handleInternal(exchange, config, preFlightRequest);
}