jmesnil / stomp-websocket

Stomp client for Web browsers and node.js apps
http://jmesnil.net/stomp-websocket/doc/
Apache License 2.0
1.43k stars 586 forks source link

Avoid mutating header objects passed as arguments #107

Open wemrysi opened 9 years ago

wemrysi commented 9 years ago

Currently, Frame.toString, Client.connect, Client.send, Client.subscribe, Client.ack and Client.nack mutate the headers argument they are invoked with. This causes very subtle bugs in client code as these objects are modified without the caller's knowledge.

Instead, a copy of the headers should be made for the purpose of modification, leaving the original in tact.

Forusim commented 9 years ago

Noticed the same issue. My workaround:

function headers() { return { persistent: true }; }

client.subscribe('/queue/test', on_message, headers());