better header parsing (invalid handshake response)