コード例 #1
0
        private static void PreSendRequest <T>(ZipatoClient zipatoClient, RestRequest restRequest, bool byPassCheckInitialized) where T : class
        {
            if (zipatoClient == null)
            {
                throw new ArgumentNullException("zipatoClient");
            }

            if (!byPassCheckInitialized)
            {
                zipatoClient.CheckInitialized();
            }
            restRequest.AddHeader("Cookie", "JSESSIONID=" + zipatoClient.Jessionid);
        }
コード例 #2
0
        internal static async Task <RestResponse <T> > SendWithPolicyAsync <T>(this RestClient restClient, ZipatoClient zipatoClient, RestRequest restRequest,
                                                                               CancellationToken cancellationToken = default(CancellationToken), bool retryHttpPostAndPut = true, bool byPassCheckInitialized = false) where T : class
        {
            PreSendRequest <T>(zipatoClient, restRequest, byPassCheckInitialized);

            if (!zipatoClient.UsePollyTransientFaultHandling)
            {
                return(await restClient.SendAsync <T>(restRequest, cancellationToken));
            }

            try
            {
                var retVal = await SendRequestWithPolicy <T>(restClient, restRequest, cancellationToken);

                return(retVal);
            }
            catch (Exception e)
            {
                throw new RequestFailedException("Even with transient fault handling enabled, the request failed.", e);
            }
        }