Exemple #1
0
 private HttpHost(bool secure, HttpDomain domain, int port, bool portIsDefault)
 {
     Secure        = secure;
     Domain        = domain;
     Port          = port;
     PortIsDefault = portIsDefault;
 }
Exemple #2
0
        public static HttpHost From(string value, bool strict = true)
        {
            var schemeParts = value.Split(new[] { Uri.SchemeDelimiter }, StringSplitOptions.None);

            if (schemeParts.Length == 2 && (schemeParts[0] == Uri.UriSchemeHttp || schemeParts[0] == Uri.UriSchemeHttps))
            {
                var secure = schemeParts[0] == Uri.UriSchemeHttps;

                var hostnameParts = schemeParts[1].Split(PortSeparator);

                if (hostnameParts.Length == 1)
                {
                    return(From(secure, HttpDomain.From(hostnameParts[0])));
                }
                else
                {
                    var portText = hostnameParts[1];

                    if (portText.EndsWith("/"))
                    {
                        portText = portText.Substring(0, portText.Length - 1);
                    }

                    int port;

                    if (Int32.TryParse(portText, out port))
                    {
                        return(From(secure, hostnameParts[0], port));
                    }
                }
            }

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

            return(null);
        }
Exemple #3
0
 public static HttpHost From(bool secure, string domain)
 {
     return(From(secure, HttpDomain.From(domain)));
 }
Exemple #4
0
 public static HttpHost From(bool secure, HttpDomain domain)
 {
     return(new HttpHost(secure, domain, secure ? DefaultSecurePort : DefaultPort, portIsDefault: true));
 }
Exemple #5
0
        //
        // Factory
        //

        public static HttpHost From(bool secure, HttpDomain domain, int port)
        {
            return(new HttpHost(secure, domain, port, secure ? port == DefaultSecurePort : port == DefaultPort));
        }