cometd/cometd — pull request #22 by SamirTalwar (2014-10-03 00:01:23+00:00)
Title: Do not reject connection messages in the same HTTP request as others.

From the Bayeux specification:

> "A client MAY send other messages in the same HTTP request with a connection message. A server MUST handle any other message sent in the same request as a connect message after the handling of the connect message is complete."

This implies that connection messages that are sent alongside other messages should not be met with an `IOException`, but instead handled first. This is the behaviour expected by the Faye client. In this commit, this is done by sorting the messages such that the connection messages come first.

We also sort the messages such that any handshake message are seen immediately, so that we can fail quickly.

---

This pull request is intended as a proof of concept, and shouldn't be merged as-is. The code is tested manually only, and I'd like to get some automated tests in place, but I don't know where, so advice would be appreciated. I'd also like to know if I'm violating the expected style of the code in any way. I could also just be missing something fundamental. I'm not too familiar with the code, so the main point of this PR is just to get some eyes on the code so someone with more knowledge can identify what's missing.