Beispiel #1
0
        System.Collections.IEnumerator WaitForFullResponse(UnityWebRequest www, string contents, FullResponse callback, bool allowLocalUpload)
        {
            yield return(new WaitUntil(() => www.isDone));

            if (CognitiveVR_Preferences.Instance.EnableDevLogging)
            {
                Util.logDevelopment("response code to " + www.url + "  " + www.responseCode);
            }

            if (callback != null)
            {
                var headers      = www.GetResponseHeaders();
                int responsecode = (int)www.responseCode;
                if (responsecode == 200)
                {
                    //check cvr header to make sure not blocked by capture portal
                    if (!headers.ContainsKey("cvr-request-time"))
                    {
                        if (CognitiveVR_Preferences.Instance.EnableDevLogging)
                        {
                            Util.logDevelopment("capture portal error! " + www.url);
                        }
                        responsecode = 404;
                    }
                }
                callback.Invoke(www.url, contents, responsecode, www.error, www.downloadHandler.text, allowLocalUpload);
            }
            www.Dispose();
        }
Beispiel #2
0
        System.Collections.IEnumerator WaitForFullResponse(UnityWebRequest www, string contents, FullResponse callback, bool autoDispose)
        {
            float time    = 0;
            float timeout = 10;

            //yield return new WaitUntil(() => www.isDone);
            while (time < timeout)
            {
                yield return(null);

                if (www == null)
                {
                    break;
                }
                if (www.isDone)
                {
                    break;
                }
                time += Time.deltaTime;
            }

            if (www == null)
            {
                Debug.LogError("WaitForFullResponse request is null!");
                yield break;
            }


            if (CognitiveVR_Preferences.Instance.EnableDevLogging)
            {
                Util.logDevelopment("response code to " + www.url + "  " + www.responseCode);
            }
            lastDataResponse = (int)www.responseCode;
            if (callback != null)
            {
                var headers      = www.GetResponseHeaders();
                int responsecode = (int)www.responseCode;
                if (responsecode == 200)
                {
                    //check cvr header to make sure not blocked by capture portal
                    if (!headers.ContainsKey("cvr-request-time"))
                    {
                        if (CognitiveVR_Preferences.Instance.EnableDevLogging)
                        {
                            Util.logDevelopment("capture portal error! " + www.url);
                        }
                        responsecode     = 404;
                        lastDataResponse = responsecode;
                    }
                }
                callback.Invoke(www.url, contents, responsecode, www.error, www.downloadHandler.text);
            }
            if (autoDispose)
            {
                www.Dispose();
            }
            activeRequests.Remove(www);
        }
Beispiel #3
0
        System.Collections.IEnumerator WaitForFullResponse(WWW www, string contents, FullResponse callback, bool allowLocalUpload)
        {
            yield return(www);

            if (callback != null)
            {
                var headers      = www.responseHeaders;
                int responsecode = Util.GetResponseCode(headers);
                if (responsecode == 200)
                {
                    //check cvr header to make sure not blocked by capture portal
                    if (!headers.ContainsKey("cvr-request-time"))
                    {
                        responsecode = 404;
                    }
                }
                callback.Invoke(www.url, contents, responsecode, www.error, www.text, allowLocalUpload);
            }
        }