Improve failure handling in HTTP