the base class waits for 30 seconds, which is too long for local thing like we are doing
Inheritance: System.Net.WebClient
Exemple #1
0
        public static string GetString(EnhancedImageServer server, string endPoint, string query = "",
			ContentType returnType = ContentType.Text, EndpointHandler handler = null, string endOfUrlForTest = null)
        {
            if(handler != null)
            {
                server.RegisterEndpointHandler(endPoint, handler);
            }
            server.StartListening();
            var client = new WebClientWithTimeout
            {
                Timeout = 3000,
            };
            client.Headers[HttpRequestHeader.ContentType] = returnType == ContentType.Text ? "text/plain" : "application/json";

            if(endOfUrlForTest != null)
            {
                return client.DownloadString(ServerBase.ServerUrlWithBloomPrefixEndingInSlash + "api/" + endOfUrlForTest);
            }
            else
            {
                if(!string.IsNullOrEmpty(query))
                    query = "?" + query;
                return client.DownloadString(ServerBase.ServerUrlWithBloomPrefixEndingInSlash + "api/" + endPoint + query);
            }
        }
Exemple #2
0
        public static string PostString(EnhancedImageServer server, string endPoint, string data, ContentType returnType,
			EndpointHandler handler = null)
        {
            if(handler != null)
            {
                server.RegisterEndpointHandler(endPoint, handler);
            }
            server.StartListening();
            var client = new WebClientWithTimeout
            {
                Timeout = 3000
            };
            client.Headers[HttpRequestHeader.ContentType] = returnType == ContentType.Text ? "text/plain" : "application/json";

            return client.UploadString(ServerBase.ServerUrlWithBloomPrefixEndingInSlash + "api/" + endPoint, "POST", data);
        }
        private static void VerifyWeAreNowListening()
        {
            try
            {
                var x = new WebClientWithTimeout {Timeout = 3000};

                if("OK" != x.DownloadString(ServerUrlWithBloomPrefixEndingInSlash + "testconnection"))
                {
                    throw new ApplicationException(GetServerStartFailureMessage());
                }
            }
            catch(Exception error)
            {
                SIL.Reporting.ErrorReport.NotifyUserOfProblem(error,GetServerStartFailureMessage());
                Application.Exit();
            }
        }