stompgem / stomp

A ruby gem for sending and receiving messages from a Stomp protocol compliant message queue. Includes: failover logic, ssl support.
http://stomp.github.com
Apache License 2.0
152 stars 80 forks source link

Trailing newline fix + other minor stuff #18

Closed tommay closed 13 years ago

tommay commented 13 years ago

The jruby workaround for handling trailing newlines didn't work for me. I kept getting timeouts. (The timeouts also seem to have issues under jruby but that doesn't matter for this pull request.) Looking at the code, using read_socket.ready? to drain trailing newlines looked race-prone and wacky even when it "worked" with MRI. I switched things up to treat trailing newlines from one message as preceding newlines on the next message. I've tested with 1.8.7 and jruby in 1.8 and 1.9 modes.

Another commit handles eof while reading the headers.

The third uses << instead of += when concatenating strings from the server. No need to create a new object every time, and avoid O(n^2) when no content-length is given.

morellon commented 13 years ago

Hi Tom, Thanks very much for contributing. I will run some tests and merge it asap.