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)); } } }
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)); } }