fix bugs in retrieveCaseInsensitiveHeader