0

I put a date-time (for example: 2020-03-20 13:56:57) into Spring STOMP headers, like this:

map.put("messageTime","2020-03-20 13:56:57");
simpMessagingTemplate.convertAndSend("","",map)

The STOMP client is like this:

stomp.subscribe("",(res)=>{
   let messageTime = res.headers.messageTime;
})

The client result displays like this:

messageTime:2020-03-20 13\c56\c57

: is converted to \c. Why?

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Mushif
  • 1
  • 1
  • Did my answer address your comment? If so please mark it as correct to help other users who have this same question in the future. If not please elaborate as to what is lacking. Thanks! – Justin Bertram Jun 24 '20 at 19:16

1 Answers1

0

This happens due to the STOMP specification which states (emphasis mine):

C style string literal escapes are used to encode any carriage return, line feed or colon that are found within the UTF-8 encoded headers. When decoding frame headers, the following transformations MUST be applied:

  • \r (octet 92 and 114) translates to carriage return (octet 13)
  • \n (octet 92 and 110) translates to line feed (octet 10)
  • \c (octet 92 and 99) translates to : (octet 58)
  • \\ (octet 92 and 92) translates to \ (octet 92)
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43