Implemented sub-protocol detection for SSL/HTTP/HTTPS
Reworked code to better handle host-based protocols