Adds handling of HTTP 400 errors (BadRequest) and ensures that HEAD requests still return error messages.