Esempio n. 1
0
        private T doReqForJSON <T>(string url, string method, HttpStatusCode expectedCode, string payload = null, cancellableDateTime deadline = null)
        {
            if (deadline == null)
            {
                deadline = new cancellableDateTime(TimeSpan.FromMinutes(4));
            }

            while (true)
            {
                resp r = doReq(url, method, expectedCode, payload, deadline);

                if (r.text.Contains("The request has timed out"))
                {
                    deadline.doCancellableSleep(TimeSpan.FromSeconds(3));
                }
                else
                {
                    return(JsonConvert.DeserializeObject <T>(r.text));
                }
            }
        }
Esempio n. 2
0
        private resp doReq(string url, string method, HttpStatusCode expectedCode, string payload = null, cancellableDateTime deadline = null, TimeSpan timeout = default(TimeSpan))
        {
            if (deadline == null)
            {
                deadline = new cancellableDateTime(TimeSpan.FromMinutes(4));
            }

            while (true)
            {
                resp toRet = _doReq(url, method, expectedCode, payload, timeout);
                if (toRet != null)
                {
                    return(toRet);
                }

                if (!deadline.stillOK)
                {
                    throw new nasAccessException();
                }

                deadline.doCancellableSleep(TimeSpan.FromSeconds(10));
            }
        }