Fix bug in HTTP upgrade implementation