Simplify the HTTP methods and clean up error handling.

There was a lot of repetition in the methods for coping with what are quite
common error states. This is now handled in one place.