Factored out http functions.