예제 #1
0
        public new static HttpLink From(string value, bool strict = true)
        {
            var schemeParts = value.Split(new[] { Uri.SchemeDelimiter }, StringSplitOptions.None);

            if (schemeParts.Length == 2)
            {
                var pathSeparatorIndex = schemeParts[1].IndexOf('/');

                if (pathSeparatorIndex == -1 || pathSeparatorIndex == schemeParts[1].Length - 1)
                {
                    var host = HttpHost.From(value, strict: false);

                    if (host != null)
                    {
                        return(new HttpLink(host, HttpResource.Root));
                    }
                }
                else
                {
                    var hostText     = schemeParts[0] + Uri.SchemeDelimiter + schemeParts[1].Substring(0, pathSeparatorIndex);
                    var resourceText = schemeParts[1].Substring(pathSeparatorIndex + 1);

                    var host = HttpHost.From(hostText, strict: false);

                    if (host != null)
                    {
                        var resource = HttpResource.From(resourceText, strict: false);

                        if (resource != null)
                        {
                            return(new HttpLink(host, resource));
                        }
                    }
                }
            }

            ExpectNot(strict, "Failed to parse HTTP link: " + value);

            return(null);
        }
예제 #2
0
        public static HttpLink From(string host, string resource, bool strict = true)
        {
            var parsedHost = HttpHost.From(host, strict);

            return(parsedHost == null ? null : From(parsedHost, resource, strict));
        }
예제 #3
0
        public static HttpLink From(HttpHost host, string resource, bool strict = true)
        {
            var parsedResource = HttpResource.From(resource, strict);

            return(parsedResource == null ? null : new HttpLink(host, parsedResource));
        }
예제 #4
0
        //
        // Factory
        //

        public static HttpLink From(HttpHost host, HttpResource resource)
        {
            return(new HttpLink(host, resource));
        }
예제 #5
0
 private HttpLink(HttpHost host, HttpResource resource)
 {
     Host     = host;
     Resource = resource;
 }
예제 #6
0
 public static HttpLink From(HttpHost host)
 {
     return(From(host, HttpResource.Root));
 }