@@ -81,7 +81,10 @@ public byte[] encode(Map<String, Object> headers, byte[] payload) {
81
81
}
82
82
else {
83
83
StompCommand command = StompHeaderAccessor .getCommand (headers );
84
- Assert .notNull (command , "Missing STOMP command: " + headers );
84
+ if (command == null ) {
85
+ throw new IllegalStateException ("Missing STOMP command: " + headers );
86
+ }
87
+
85
88
output .write (command .toString ().getBytes (StandardCharsets .UTF_8 ));
86
89
output .write (LF );
87
90
writeHeaders (command , headers , payload , output );
@@ -115,22 +118,25 @@ private void writeHeaders(StompCommand command, Map<String, Object> headers, byt
115
118
boolean shouldEscape = (command != StompCommand .CONNECT && command != StompCommand .CONNECTED );
116
119
117
120
for (Entry <String , List <String >> entry : nativeHeaders .entrySet ()) {
118
- byte [] key = encodeHeaderString (entry .getKey (), shouldEscape );
119
121
if (command .requiresContentLength () && "content-length" .equals (entry .getKey ())) {
120
122
continue ;
121
123
}
124
+
122
125
List <String > values = entry .getValue ();
123
126
if (StompCommand .CONNECT .equals (command ) &&
124
127
StompHeaderAccessor .STOMP_PASSCODE_HEADER .equals (entry .getKey ())) {
125
128
values = Arrays .asList (StompHeaderAccessor .getPasscode (headers ));
126
129
}
130
+
131
+ byte [] encodedKey = encodeHeaderString (entry .getKey (), shouldEscape );
127
132
for (String value : values ) {
128
- output .write (key );
133
+ output .write (encodedKey );
129
134
output .write (COLON );
130
135
output .write (encodeHeaderString (value , shouldEscape ));
131
136
output .write (LF );
132
137
}
133
138
}
139
+
134
140
if (command .requiresContentLength ()) {
135
141
int contentLength = payload .length ;
136
142
output .write ("content-length:" .getBytes (StandardCharsets .UTF_8 ));
0 commit comments