private Task<HttpResponseMessage> HandleUnauthenticatedRequestImpl(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            try
            {
                UnauthenticatedRequestContext unauthanticatedRequestContext = new UnauthenticatedRequestContext(request);
                HandleUnauthenticatedRequest(unauthanticatedRequestContext);

                if (unauthanticatedRequestContext.Response != null)
                {
                    EnsureRequestMessageExistence(unauthanticatedRequestContext.Response, request);
                    return Task.FromResult<HttpResponseMessage>(unauthanticatedRequestContext.Response);
                }

                return base.SendAsync(request, cancellationToken);
            }
            catch (Exception e)
            {
                throw;
            }
        }
 /// <summary>
 /// Called when the request is unauthenticated.
 /// </summary>
 /// <param name="context">Context object which carries the HTTP request message to send to the server and the empty HTTP response property.</param>
 protected virtual void HandleUnauthenticatedRequest(UnauthenticatedRequestContext context)
 {
     HttpResponseMessage unauthorizedResponseMessage = context.Request.CreateResponse(HttpStatusCode.Unauthorized);
     unauthorizedResponseMessage.Headers.Add("WWW-Authenticate", _httpBasicSchemeName);
     context.Response = unauthorizedResponseMessage;
 }