|
|
@ -29,6 +29,7 @@ import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.context.Lifecycle; |
|
|
|
import org.springframework.context.Lifecycle; |
|
|
|
|
|
|
|
import org.springframework.core.log.LogFormatUtils; |
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.server.ServerHttpRequest; |
|
|
|
import org.springframework.http.server.ServerHttpRequest; |
|
|
@ -291,7 +292,8 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life |
|
|
|
|
|
|
|
|
|
|
|
protected void handleInvalidUpgradeHeader(ServerHttpRequest request, ServerHttpResponse response) throws IOException { |
|
|
|
protected void handleInvalidUpgradeHeader(ServerHttpRequest request, ServerHttpResponse response) throws IOException { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
logger.error("Handshake failed due to invalid Upgrade header: " + request.getHeaders().getUpgrade()); |
|
|
|
logger.error(LogFormatUtils.formatValue( |
|
|
|
|
|
|
|
"Handshake failed due to invalid Upgrade header: " + request.getHeaders().getUpgrade(), -1, true)); |
|
|
|
} |
|
|
|
} |
|
|
|
response.setStatusCode(HttpStatus.BAD_REQUEST); |
|
|
|
response.setStatusCode(HttpStatus.BAD_REQUEST); |
|
|
|
response.getBody().write("Can \"Upgrade\" only to \"WebSocket\".".getBytes(StandardCharsets.UTF_8)); |
|
|
|
response.getBody().write("Can \"Upgrade\" only to \"WebSocket\".".getBytes(StandardCharsets.UTF_8)); |
|
|
@ -299,7 +301,8 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life |
|
|
|
|
|
|
|
|
|
|
|
protected void handleInvalidConnectHeader(ServerHttpRequest request, ServerHttpResponse response) throws IOException { |
|
|
|
protected void handleInvalidConnectHeader(ServerHttpRequest request, ServerHttpResponse response) throws IOException { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
logger.error("Handshake failed due to invalid Connection header " + request.getHeaders().getConnection()); |
|
|
|
logger.error(LogFormatUtils.formatValue( |
|
|
|
|
|
|
|
"Handshake failed due to invalid Connection header" + request.getHeaders().getConnection(), -1, true)); |
|
|
|
} |
|
|
|
} |
|
|
|
response.setStatusCode(HttpStatus.BAD_REQUEST); |
|
|
|
response.setStatusCode(HttpStatus.BAD_REQUEST); |
|
|
|
response.getBody().write("\"Connection\" must be \"upgrade\".".getBytes(StandardCharsets.UTF_8)); |
|
|
|
response.getBody().write("\"Connection\" must be \"upgrade\".".getBytes(StandardCharsets.UTF_8)); |
|
|
@ -323,8 +326,9 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life |
|
|
|
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) { |
|
|
|
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
if (logger.isErrorEnabled()) { |
|
|
|
String version = request.getHeaders().getFirst("Sec-WebSocket-Version"); |
|
|
|
String version = request.getHeaders().getFirst("Sec-WebSocket-Version"); |
|
|
|
logger.error("Handshake failed due to unsupported WebSocket version: " + version + |
|
|
|
logger.error(LogFormatUtils.formatValue( |
|
|
|
". Supported versions: " + Arrays.toString(getSupportedVersions())); |
|
|
|
"Handshake failed due to unsupported WebSocket version: " + version + |
|
|
|
|
|
|
|
". Supported versions: " + Arrays.toString(getSupportedVersions()), -1, true)); |
|
|
|
} |
|
|
|
} |
|
|
|
response.setStatusCode(HttpStatus.UPGRADE_REQUIRED); |
|
|
|
response.setStatusCode(HttpStatus.UPGRADE_REQUIRED); |
|
|
|
response.getHeaders().set(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION, |
|
|
|
response.getHeaders().set(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION, |
|
|
|