Factored out the HTTP stuff to get clean wrapper code