Support STOMP in addition to CONNECT frame

One is literally an alias for the other with "the advantage that a
protocol sniffer/discriminator will be able to differentiate the STOMP
connection from an HTTP connection".

Closes gh-22652
This commit is contained in:
Rossen Stoyanchev
2019-03-27 16:19:11 -04:00
parent 50acbae4cf
commit 1aaadb39c0
6 changed files with 20 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -521,7 +521,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
return;
}
if (StompCommand.CONNECT.equals(command)) {
if (StompCommand.CONNECT.equals(command) || StompCommand.STOMP.equals(command)) {
if (logger.isDebugEnabled()) {
logger.debug(stompAccessor.getShortLogMessage(EMPTY_PAYLOAD));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -138,7 +138,8 @@ public class StompEncoder {
return;
}
boolean shouldEscape = (command != StompCommand.CONNECT && command != StompCommand.CONNECTED);
boolean shouldEscape = (command != StompCommand.CONNECT && command != StompCommand.STOMP
&& command != StompCommand.CONNECTED);
for (Entry<String, List<String>> entry : nativeHeaders.entrySet()) {
if (command.requiresContentLength() && "content-length".equals(entry.getKey())) {
@@ -146,7 +147,7 @@ public class StompEncoder {
}
List<String> values = entry.getValue();
if (StompCommand.CONNECT.equals(command) &&
if ((StompCommand.CONNECT.equals(command) || StompCommand.STOMP.equals(command)) &&
StompHeaderAccessor.STOMP_PASSCODE_HEADER.equals(entry.getKey())) {
values = Collections.singletonList(StompHeaderAccessor.getPasscode(headers));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 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.
@@ -160,7 +160,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
super.setSubscriptionId(value);
}
}
else if (StompCommand.CONNECT.equals(command)) {
else if (StompCommand.CONNECT.equals(command) || StompCommand.STOMP.equals(command)) {
protectPasscode();
}
}
@@ -425,6 +425,10 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
Principal user = getUser();
return "CONNECT" + (user != null ? " user=" + user.getName() : "") + appendSession();
}
else if (StompCommand.STOMP.equals(command)) {
Principal user = getUser();
return "STOMP" + (user != null ? " user=" + user.getName() : "") + appendSession();
}
else if (StompCommand.CONNECTED.equals(command)) {
return "CONNECTED heart-beat=" + Arrays.toString(getHeartbeat()) + appendSession();
}