How To Get Http Status Code from WWW in WebGL?

I’m writing a program communicating web server with HTTP(S).

I can get Http Status Code in Editor in following way.

WWW w = new WWW(url, postData, reqHeaders);
// wait for while.
if (w.isDone) {
    string statusLine = w.responseHeaders["STATUS"];
    // parse statusLine and obtain status code.
}

However it seems responseHeaders doesn’t include “STATUS” key-value pair in WebGL environment.
Is it intended behavior?

Or accessing to responseHeaders[“STATUS”] is not a formal way to obtain status code?
As far as I can see Status Line is NOT a part of response headers in RFC’s definition.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

I lost what is the expected way to check the HTTP status code since I can not find method/variable to obtain the status code unlike other HTTP client libraries.

Use UnityWebRequest instead of WWW - it’s fairly easy to swap in.

See also: http://docs.unity3d.com/ScriptReference/Experimental.Networking.UnityWebRequest-responseCode.html

1 Like

Thank you.
I’ll investigate it.