List of usage examples for org.springframework.web.cors.reactive CorsUtils isPreFlightRequest
public static boolean isPreFlightRequest(ServerHttpRequest request)
From source file:org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.CloudFoundrySecurityInterceptor.java
Mono<SecurityResponse> preHandle(ServerWebExchange exchange, String endpointId) { ServerHttpRequest request = exchange.getRequest(); if (CorsUtils.isPreFlightRequest(request)) { return SUCCESS; }/*from ww w. j av a 2 s. c o m*/ if (!StringUtils.hasText(this.applicationId)) { return Mono.error(new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, "Application id is not available")); } if (this.cloudFoundrySecurityService == null) { return Mono.error(new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, "Cloud controller URL is not available")); } return check(exchange, endpointId).then(SUCCESS).doOnError(this::logError) .onErrorResume(this::getErrorResponse); }
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; }/* w ww .j av a2 s .c o m*/ 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); }