updated http handshake for better compatibility