An attempt to obtain www.responseHeaders cauzes exception

Hi all.
I recently updated my project to unity 2017.1.0p5 and meat strange behaviour.
When i load local file using WWW class and then try to check responseHeaders property of WWW class instance. It throws exception:

ERROR:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.WWW.get_responseHeaders () (at C:/buildslave/unity/build/Runtime/WebRequestWWW/UWRWWW.cs:158)
TestLocalLoading+<LoadLocalFile>c__Iterator0.MoveNext () (at Assets/Scripts/TestLocalLoading.cs:20)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

SAMPLE CODE:

public class TestLocalLoading : MonoBehaviour
{
    public void TesLoacalLoading()
    {
        StartCoroutine(LoadLocalFile());
    }

    private static IEnumerator LoadLocalFile()
    {
        var filePath = "file://" + Application.dataPath + "/TestLocalLoading.txt";
        var www = new WWW(filePath);

        while (!www.isDone)
            yield return www;

        Debug.LogFormat("www.text: {0}", www.text); // file loaded correctly
        Debug.LogFormat("www.responseHeaders: {0}", www.responseHeaders); // this line produce exception
    }
}

It’s just a simple code to reproduce error.
In Unity 5.3.4p1 all was fine. But since WWW became a wrapper for UnityWebRequest I start getting errors.

I’m having the exact same problem with Unity 2017.1.1p3, the previous version 5.4.1p1 that I used doesn’t have this problem. I believe this is a bug in the responseHeaders getter. @sergey-samus since you’ve already have a simple repro, could you please report a bug so that the Unity team can get it fixed?

The fix for this bug is on the way (but it will take a while for it go through backporting & release pipeline).
The issue is that since 2017.1 WWW.responseHeaders can return null when there are no headers. This will be fixed soon to return empty dictionary.

Is there any patch build that contains a fix for this? Thanks.

Not yet.

There’s a different issue here as well. In the case reported by sergey, WWW.responseHeaders does not return null, trying to access it throws an exception.

As far as I can tell, accessing WWW.responseHeaders will throw a NullReferenceException if the response body is empty, even if there are response headers.

Correct. This is the other bug, a fix is in the pipeline, will come out soon.

We’re interested in these fixes as well, thank you

We need it too.

I’m also interested in a timeline for a fix. This has broken our plugin for all our customers that upgrade to 2017.X.

We tried UnityWebRequest (Unity - Scripting API: UnityWebRequest) and after a quick test here it doesn’t seem to have the same problems obtaining headers.