Backport HTTPS changes to HTTP code.