What is a good way to determine if a UnityWebRequest succeeded?

The samples in the manual show using UnityWebRequest.isError method. Unfortunately (see the docs for that field) isError returns false when the web server returns an error such as 404 Not Found.

What would be a good way to determine if your web request succeeded in returning data that you can use? I’m thinking of something like this:

    private bool IsFailedRequest(UnityWebRequest request)
    {
        return request.isError || (request.responseCode != (long)System.Net.HttpStatusCode.OK);
    }

But I’m concerned that there may be other success status codes that I should be checking for. Also, although I’m getting 200 (HttpStatusCode.OK) back from a successful UnityWebRequest.Get, the result from a successful UnityWebRequest.GetAssetBundle call is returning 0 (not a status code). Is there a better way to check for success?

I found that sometimes success is returned as HttpStatusCode.OK and sometimes as 0. So far, handling it like this seems to produce the expected results:

    public static bool IsSuccess(this UnityWebRequest request)
    {
        if (request.isError) { return false; }

        if (request.responseCode == 0) { return true; }
        if (request.responseCode == (long)System.Net.HttpStatusCode.OK) { return true; }

        return false;
    }

isError is depreciated in Unity 2017.

Check for IsHttpError for HTTP responses other than 200 (success) and check isNetworkError for system errors.