/// <summary>
        /// Calls a simple endpoint outside of the CustomInstrumentationController to get the agent started up.
        /// </summary>
        public void InitializeApp()
        {
            var address = $"http://{DestinationServerName}:{Port}/";
            var result  = new ExtendedTimeoutWebClient().DownloadString(address);

            Assert.NotNull(result);
            Assert.Contains("It am working", result);
        }
        private string ExtendedTimeoutDownloadStringAndAssertEqual(string address, string expectedContent)
        {
            var result = new ExtendedTimeoutWebClient().DownloadString(address);

            Assert.NotNull(result);
            Assert.Equal(expectedContent, result);

            return(result);
        }
Пример #3
0
        public ContentSyncResult Sync(string url)
        {
            var importText = string.Empty;

            try
            {
                var client = new ExtendedTimeoutWebClient();

                importText = System.Text.Encoding.Default.GetString(client.DownloadData(url));
            }
            catch (WebException ex)
            {
                var httpWebResponse = ((HttpWebResponse)ex.Response);

                if (httpWebResponse == null)
                {
                    Logger.Error(ex, "There was an error exporting the remote site at {0}. The error response did not contain an HTTP status code; this implies that there was a connectivity issue, or the request timed out", url);

                    return(new ContentSyncResult {
                        Status = ContentSyncResultStatus.RemoteUrlTimedout
                    });
                }

                var statusCode = httpWebResponse.StatusCode;

                if (statusCode == HttpStatusCode.Unauthorized)
                {
                    return(new ContentSyncResult {
                        Status = ContentSyncResultStatus.RemoteUrlUnauthorized
                    });
                }

                if (statusCode != HttpStatusCode.OK)
                {
                    Logger.Error(ex, "There was an error exporting the remote site at {0}", url);

                    return(new ContentSyncResult {
                        Status = ContentSyncResultStatus.RemoteUrlFailed
                    });
                }
            }

            return(SyncFromText(importText));
        }
        public ContentSyncResult Sync(string url) {
            var importText = string.Empty;

            try
            {
                var client = new ExtendedTimeoutWebClient();

                importText = client.DownloadString(url);
            }
            catch (WebException ex)
            {
                var httpWebResponse = ((HttpWebResponse)ex.Response);

                if (httpWebResponse == null)
                {
                    Logger.Error(ex, "There was an error exporting the remote site at {0}. The error response did not contain an HTTP status code; this implies that there was a connectivity issue, or the request timed out", url);

                    return new ContentSyncResult { Status = ContentSyncResultStatus.RemoteUrlTimedout };
                }

                var statusCode = httpWebResponse.StatusCode;

                if (statusCode == HttpStatusCode.Unauthorized)
                {
                    return new ContentSyncResult { Status = ContentSyncResultStatus.RemoteUrlUnauthorized };
                }

                if (statusCode != HttpStatusCode.OK)
                {
                    Logger.Error(ex, "There was an error exporting the remote site at {0}", url);

                    return new ContentSyncResult { Status = ContentSyncResultStatus.RemoteUrlFailed };
                }
            }

            return SyncFromText(importText);
        }