Пример #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, true);
            }
            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));
            }
        }
Пример #2
0
        public static string PostString(EnhancedImageServer server, string endPoint, string data, ContentType returnType,
                                        EndpointHandler handler = null)
        {
            if (handler != null)
            {
                server.RegisterEndpointHandler(endPoint, handler, true);
            }
            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));
        }