ZeroInstall.Central.WinForms.SyncWizard.CheckCredentials C# (CSharp) Method

CheckCredentials() private method

private CheckCredentials ( ) : void
return void
        private void CheckCredentials()
        {
            var appListUri = new Uri(_server.Uri, new Uri("app-list", UriKind.Relative));

            var request = WebRequest.Create(appListUri);
            request.Method = "HEAD";
            request.Credentials = _server.Credentials;
            request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
            request.Timeout = WebClientTimeout.DefaultTimeout;

            try
            {
                request.GetResponse();
            }
                #region Error handling
            catch (WebException ex)
                when (ex.Status == WebExceptionStatus.ProtocolError && (ex.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.Unauthorized)
            {
                // Wrap exception to add context information
                throw new WebException(Resources.SyncCredentialsInvalid, ex, ex.Status, ex.Response);
            }
            #endregion
        }
        #endregion