Changed HTTP error handling.

The previous attempt did not work.