Fixed SSL upgrade logic and tunnel CONNECT request