protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var oldSessionCookies = SessionCookies.FromCookieContainer(HttpClientHandler.CookieContainer, request.RequestUri);

            var response = await base.SendAsync(request, cancellationToken);

            var sessionCookies = SessionCookies.FromCookieContainer(HttpClientHandler.CookieContainer, request.RequestUri);

            if (sessionCookies.Valid && !oldSessionCookies.Equals(sessionCookies))
            {
                Settings.CFSession = sessionCookies.AsCookieCollection();
            }

            return(response);
        }
        private SolveResult GetSolveResult(HttpResponseMessage submissionResponse)
        {
            var sessionCookies = SessionCookies.FromCookieContainer(CloudflareHandler.HttpClientHandler.CookieContainer, SiteUrl);

            if (submissionResponse.StatusCode.Equals(HttpStatusCode.Found))
            {
                var success = submissionResponse.Headers.Contains(HttpHeaders.SetCookie) &&
                              submissionResponse.Headers.GetValues(HttpHeaders.SetCookie)
                              .Any(cookieValue => cookieValue.Contains(SessionCookies.ClearanceCookieName));

                return(new SolveResult(success, LayerCaptcha, success ? null : Errors.ClearanceCookieNotFound, DetectResult, sessionCookies, UserAgent, submissionResponse));
            }
            else
            {
                return(new SolveResult(false, LayerCaptcha, Errors.SomethingWrongHappened, DetectResult, sessionCookies, UserAgent, submissionResponse)); //"invalid submit response"
            }
        }