Unify http code for client and server.