Add headers on 'handshake'

The headers in the 'handshake' event were not written to the socket, the client received data but not the headers.
[minor] Style compliance. Fixes #402.
[minor] Strip trailing whitespace.