Hello,
I need to get HTTP STATUS CODE on web access using WWW class. I tried to parse status code from HTTP Response Header “STATUS”. That works perfect on Unity Editor.
However, if I build it to Windows Store App (Universal 10), I can’t get STATUS header because WWW.responseHeaders doesn’t have STATUS on WSA.
Please help me to get status code from WWW on WSA.
Repro code:
public void TestConnection()
{
StartCoroutine(TestConnectionImpl());
}
IEnumerator TestConnectionImpl()
{
string url = "http://unity3d.com/";
byte[] postData = null;
Dictionary<string, string> headers = new Dictionary<string, string>();
using (WWW www = new WWW(url, postData, headers))
{
while (!www.isDone)
yield return www;
if (!string.IsNullOrEmpty(www.error))
Debug.LogError("HTTP Communication error: " + www.error);
else
{
Debug.Log("HTTP Communication success.");
System.Text.StringBuilder headerBuilder = new System.Text.StringBuilder();
if (www.responseHeaders.Count > 0)
foreach (KeyValuePair<string, string> entry in www.responseHeaders)
headerBuilder.AppendLine(entry.Key + "=" + entry.Value);
Debug.Log(headerBuilder.ToString());
}
}
}
Repro Steps:
- Put the code above and call TestConnection() in your project.
- Run the code in Unity Editor.
- See the Console output. Headers start with “STATUS=HTTP/1.1 200 OK”. This is expected.
- Build the project to Windows Store App. Select “Universal 10” for SDK.
- Run the project in Visual Studio.
- See Debug output. Headers start with “SERVER=…” and there is no “STATUS” header. This is NOT expected.