Refactoring of http_tpl and https_tpl