move http code to central location