Add support for HTTPS.

Hi @eelcocramer 

* I've added support for HTTPS.
* Implemented all the JSHint suggestions.
* Made a bugfix. When receiving non-BOSH response (e.g. 301 response from Nginx), then the client went into an infinite loop.

Regards
JC