InvalidOperationException: Cannot override system-specified headers

在5.x正常工作,在2017.2.2上会出现报错如下:

InvalidOperationException: Cannot override system-specified headers

UnityEngine.Networking.UnityWebRequest.SetRequestHeader (System.String name, System.String value) (at C:/buildslave/unity/build/artifacts/generated/common/modules/UnityWebRequest/WebRequestBindings.gen.cs:471)

UnityEngine.WWW..ctor (System.String url, System.Byte[] postData, System.Collections.Generic.Dictionary`2 headers) (at C:/buildslave/unity/build/Runtime/WebRequestWWW/UWRWWW.cs:62)

出现这个错误的原因是在2017.1中,WWW类被重写为UnityWebRequest的封装,header的设置加入了更严格的规则,不准许对Content-Length进行了手动设置,这个属性会自动设置。

删掉Content-Length的设置就不会再报错啦。

你可能感兴趣的:(InvalidOperationException: Cannot override system-specified headers)