Fixes to pass the whole URL to the connection so as to get host and path. Also fixed the handshaking code since it never seemed to hit.