fiorix/cyclone — pull request #111 by flaviogrossi (2013-08-26 12:29:10+00:00)
Title: some fixes for websocket protocol 76

hi,

i think i found some problems with the current implementation of the hixie-76 protocol's handshake:

1. the received nonce should not be stripped, since the random bytes sent by the client could contain leading or trailing whitespace
2. when the http upgrade response is sent to the client, it sends a double \r\n immediately after the challenge response (token)
3. after having written the upgrade response for the client via transport.write(), a call to self.handler.flush() is made which to me seems unnecessary (and in fact it is not made for the hybi protocol). Actually, i think it may create problems, since it could append to the handshake some extra requests, especially if handler.transform is not empty

please review the attached changes in case there's something wrong

thanks,
flavio