Skip to content

Commit ecf75f2

Browse files
committed
Merge branch '6.2.x'
2 parents 088d53a + f477c16 commit ecf75f2

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

framework-docs/modules/ROOT/pages/web/websocket/stomp/ordered-messages.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ from where they are handled according to their destination prefix. As the channe
1919
a `ThreadPoolExecutor`, messages are processed in different threads, and the resulting sequence
2020
of handling may not match the exact order in which they were received.
2121

22-
To enable ordered publishing, set the `setPreserveReceiveOrder` flag as follows:
22+
To enable ordered receiving, set the `setPreserveReceiveOrder` flag as follows:
2323

2424
include-code::./ReceiveOrderWebSocketConfiguration[tag=snippet,indent=0]

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerResponseResultHandler.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,19 +50,38 @@ public class ServerResponseResultHandler implements HandlerResultHandler, Initia
5050

5151
/**
5252
* Configure HTTP message writers to serialize the request body with.
53-
* <p>By default this is set to {@link ServerCodecConfigurer}'s default writers.
53+
* <p>By default, this is set to {@link ServerCodecConfigurer}'s default writers.
5454
*/
5555
public void setMessageWriters(List<HttpMessageWriter<?>> configurer) {
5656
this.messageWriters = configurer;
5757
}
5858

59+
/**
60+
* Return the configured {@link HttpMessageWriter}'s.
61+
* @since 6.2.3
62+
*/
63+
public List<HttpMessageWriter<?>> getMessageWriters() {
64+
return this.messageWriters;
65+
}
66+
67+
/**
68+
* Set the current view resolvers.
69+
*/
5970
public void setViewResolvers(List<ViewResolver> viewResolvers) {
6071
this.viewResolvers = viewResolvers;
6172
}
6273

74+
/**
75+
* Return the configured {@link ViewResolver}'s.
76+
* @since 6.2.3
77+
*/
78+
public List<ViewResolver> getViewResolvers() {
79+
return this.viewResolvers;
80+
}
81+
6382
/**
6483
* Set the order for this result handler relative to others.
65-
* <p>By default set to 0. It is generally safe to place it early in the
84+
* <p>By default, set to 0. It is generally safe to place it early in the
6685
* order as it looks for a concrete return type.
6786
*/
6887
public void setOrder(int order) {

spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222
import java.util.Collections;
2323
import java.util.List;
2424
import java.util.Map;
25+
import java.util.Set;
2526
import java.util.function.Predicate;
2627
import java.util.stream.Collectors;
2728

@@ -65,6 +66,9 @@
6566
*/
6667
public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
6768

69+
// For WebSocket upgrades in HTTP/2 (see RFC 8441)
70+
private static final HttpMethod CONNECT_METHOD = HttpMethod.valueOf("CONNECT");
71+
6872
private static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
6973

7074
private static final String SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol";
@@ -194,9 +198,9 @@ public Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler han
194198
HttpMethod method = request.getMethod();
195199
HttpHeaders headers = request.getHeaders();
196200

197-
if (HttpMethod.GET != method) {
201+
if (HttpMethod.GET != method && CONNECT_METHOD != method) {
198202
return Mono.error(new MethodNotAllowedException(
199-
request.getMethod(), Collections.singleton(HttpMethod.GET)));
203+
request.getMethod(), Set.of(HttpMethod.GET, CONNECT_METHOD)));
200204
}
201205

202206
if (!"WebSocket".equalsIgnoreCase(headers.getUpgrade())) {

spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import java.util.List;
2626
import java.util.Locale;
2727
import java.util.Map;
28+
import java.util.Set;
2829

2930
import org.apache.commons.logging.Log;
3031
import org.apache.commons.logging.LogFactory;
@@ -67,6 +68,10 @@
6768
*/
6869
public abstract class AbstractHandshakeHandler implements HandshakeHandler, Lifecycle {
6970

71+
// For WebSocket upgrades in HTTP/2 (see RFC 8441)
72+
private static final HttpMethod CONNECT_METHOD = HttpMethod.valueOf("CONNECT");
73+
74+
7075
protected final Log logger = LogFactory.getLog(getClass());
7176

7277
private final RequestUpgradeStrategy requestUpgradeStrategy;
@@ -169,11 +174,12 @@ public final boolean doHandshake(ServerHttpRequest request, ServerHttpResponse r
169174
logger.trace("Processing request " + request.getURI() + " with headers=" + headers);
170175
}
171176
try {
172-
if (HttpMethod.GET != request.getMethod()) {
177+
HttpMethod httpMethod = request.getMethod();
178+
if (HttpMethod.GET != httpMethod && CONNECT_METHOD != httpMethod) {
173179
response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED);
174-
response.getHeaders().setAllow(Collections.singleton(HttpMethod.GET));
180+
response.getHeaders().setAllow(Set.of(HttpMethod.GET, CONNECT_METHOD));
175181
if (logger.isErrorEnabled()) {
176-
logger.error("Handshake failed due to unexpected HTTP method: " + request.getMethod());
182+
logger.error("Handshake failed due to unexpected HTTP method: " + httpMethod);
177183
}
178184
return false;
179185
}
@@ -255,7 +261,7 @@ protected String[] getSupportedVersions() {
255261

256262
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) {
257263
if (logger.isErrorEnabled()) {
258-
String version = request.getHeaders().getFirst("Sec-WebSocket-Version");
264+
String version = request.getHeaders().getFirst(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION);
259265
logger.error(LogFormatUtils.formatValue(
260266
"Handshake failed due to unsupported WebSocket version: " + version +
261267
". Supported versions: " + Arrays.toString(getSupportedVersions()), -1, true));

0 commit comments

Comments
 (0)