Polish WebSocket-related

master
Rossen Stoyanchev 7 years ago
parent c30145d6f9
commit e818b904ad
  1. 23
      spring-web/src/main/java/org/springframework/web/cors/reactive/CorsProcessor.java
  2. 2
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/TomcatWebSocketClient.java
  3. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/RequestUpgradeStrategy.java
  4. 2
      spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,20 +16,14 @@
package org.springframework.web.cors.reactive;
import reactor.core.publisher.Mono;
import org.springframework.lang.Nullable;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.server.ServerWebExchange;
/**
* A strategy that takes a reactive HTTP exchange and a {@link CorsConfiguration} and
* updates the response.
*
* <p>This component is not concerned with how a {@code CorsConfiguration} is
* selected but rather takes follow-up actions such as applying CORS validation
* checks and either rejecting the response or adding CORS headers to the
* response.
* A strategy to apply CORS validation checks and updates to a
* {@link ServerWebExchange}, either rejecting through the response or adding
* CORS related headers, based on a pre-selected {@link CorsConfiguration}.
*
* @author Sebastien Deleuze
* @author Rossen Stoyanchev
@ -39,10 +33,11 @@ import org.springframework.web.server.ServerWebExchange;
public interface CorsProcessor {
/**
* Process an HTTP exchange given a {@code CorsConfiguration}.
* @param configuration the applicable CORS configuration (possibly {@code null})
* @param exchange the current HTTP request / response
* @return a {@link Mono} emitting {@code false} if the request is rejected, {@code true} otherwise
* Process a request using the given {@code CorsConfiguration}.
* @param configuration the CORS configuration to use; possibly {@code null}
* in which case pre-flight requests are rejected, but all others allowed.
* @param exchange the current exchange
* @return {@code false} if the request was rejected, {@code true} otherwise
*/
boolean process(@Nullable CorsConfiguration configuration, ServerWebExchange exchange);

@ -23,6 +23,7 @@ import org.springframework.web.reactive.socket.HandshakeInfo;
import org.springframework.web.reactive.socket.adapter.StandardWebSocketSession;
import org.springframework.web.reactive.socket.adapter.TomcatWebSocketSession;
import org.apache.tomcat.websocket.WsWebSocketContainer;
import reactor.core.publisher.MonoProcessor;
/**
@ -35,6 +36,7 @@ public class TomcatWebSocketClient extends StandardWebSocketClient {
public TomcatWebSocketClient() {
this(new WsWebSocketContainer());
}
public TomcatWebSocketClient(WebSocketContainer webSocketContainer) {

@ -46,6 +46,7 @@ public interface RequestUpgradeStrategy {
* @return completion {@code Mono<Void>} to indicate the outcome of the
* WebSocket session handling.
*/
Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler webSocketHandler, @Nullable String subProtocol);
Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler webSocketHandler,
@Nullable String subProtocol);
}

@ -92,7 +92,7 @@ public abstract class AbstractWebSocketIntegrationTests {
public static Object[][] arguments() throws IOException {
WebSocketClient[] clients = new WebSocketClient[] {
new TomcatWebSocketClient(new WsWebSocketContainer()),
new TomcatWebSocketClient(),
new JettyWebSocketClient(),
new ReactorNettyWebSocketClient(),
new UndertowWebSocketClient(Xnio.getInstance().createWorker(OptionMap.EMPTY))

Loading…
Cancel
Save