Convert docker host URL to an http URL
339660
public static String convertTcpToHttpUrl(String connect) {
        String protocol = connect.contains(":" + DOCKER_HTTPS_PORT) ? "https:" : "http:";
        return connect.replaceFirst("^tcp:", protocol);
    }
180266
def to_host(self):
        """"""
        return Host(self.address,
                    alias=self.alias,
                    user=self.user,
                    keyfile=self.keyfile,
                    port=self.port,
                    extra=self.extra)
1343002
def request_host(request):
    
    url = request.get_full_url()
    parse_result = compat.urlparse.urlparse(url)
    scheme, host, port = parse_result.scheme, parse_result.hostname, parse_result.port
    try:
        port = int(port)
    except ValueError:
        pass
    if host == "":
        host = request.get_header("Host", "")

    if port != default_ports.get(scheme):
        host = "%s:%s" % (host, port)
    return host
559252
def _buildUrl(self):
		""""""
		return '%(protocol)s://%(host)s:%(port)s%(address)s'%{
			'protocol': self._protocol,
			'host': self._host,
			'port': self._port,
			'address': self._address,
		}
1294076
def _create_container_ship(self, host_data=None):
        
        if not host_data:
            host_data = {}
            path = os.getenv('DOCKER_CERT_PATH')
            host_data['address'] = os.getenv('DOCKER_HOST')

            if not host_data:
                raise LookupError(
                    logger.error("Unable to find docker ENV var: DOCKER_HOST, DOCKER_CERT_PATH, and DOCKER_TLS_VERIFY are required.")
                )

            if not host_data.get('address'):
                raise LookupError(logger.error("Unable to find a value for DOCKER_HOST."))

            if 'tcp://' in host_data['address']:
                host_data['address'] = host_data['address'].replace('tcp://', 'https://')

            host_data['ssl_cert_path'] = os.path.realpath(path)
            host_data['verify']        = os.getenv('DOCKER_TLS_VERIFY')

            if host_data['verify'] == 'yes':
                host_data['verify'] = True
            elif host_data['verify'] == 'no':
                host_data['verify'] = False

        return ContainerShip(
            host_data.get('address'),
            services=host_data.get('services'),
            ssl_cert_path=host_data.get('ssl_cert_path'),
            verify=host_data.get('verify')
        )
1353246
def hosts_to_endpoints(hosts, port=2181):
    
    endpoints = []
    for host in hosts.split(","):
        endpoints.append(tuple(host.rsplit(":", 1)) if ":" in host else (host, port))
    return endpoints
1186775
def host_port_prefix(host, port, prefix):
    """"""
    uri = "http://" + host
    if (port != 80):
        uri += ':' + str(port)
    if (prefix):
        uri += '/' + prefix
    return uri
806905
def parse_url(self):
        
        self.scheme = None
        self.resource = None
        self.host = None
        self.port = None

        if self.url is None:
            return

        scheme, url = self.url.split(":", 1)
        parsed = urlsplit(url, scheme="http")
        if parsed.hostname:
            self.host = parsed.hostname
        elif '+unix' in scheme:
            self.host = 'localhost'
        else:
            raise ValueError("Invalid hostname from: %s", self.url)

        if parsed.port:
            self.port = parsed.port

        if scheme == "ws":
            if not self.port:
                self.port = 8080
        elif scheme == "wss":
            if not self.port:
                self.port = 443
        elif scheme in ('ws+unix', 'wss+unix'):
            pass
        else:
            raise ValueError("Invalid scheme: %s" % scheme)

        if parsed.path:
            resource = parsed.path
        else:
            resource = "/"

        if '+unix' in scheme:
            self.unix_socket_path = resource
            resource = '/'

        if parsed.query:
            resource += "?" + parsed.query

        self.scheme = scheme
        self.resource = resource
89406
def generate_url(self, suffix):
        """"""
        url_base_path = os.path.dirname(self.path)
        netloc = "{}:{}".format(*self.server.server_address)
        return urlunparse((
            "http",
            netloc,
            url_base_path + "/" + suffix,
            "", "", ""))
901687
def url(self):
        """"""
        return URL.format(http=self.web_proto, host=self.host, port=self.port)
542107
def get_base_url(use_ssl, instance=None, host=None):
        

        if instance is not None:
            host = ("%s.service-now.com" % instance).rstrip('/')

        if use_ssl is True:
            return "https://%s" % host

        return "http://%s" % host
847666
def docker_routable_ip
      case @docker_url.scheme
      when 'tcp', 'http', 'https'
        docker_dns = @docker_url.host
        docker_port = @docker_url.port || 2376
      else
        # Cheap trick: for unix, file or other protocols, assume docker ports
        # are proxied to localhost in addition to other interfaces
        docker_dns = 'localhost'
        docker_port = 2376
      end

      addr = Addrinfo.getaddrinfo(
        docker_dns, docker_port,
        Socket::AF_INET, Socket::SOCK_STREAM).first

      addr && addr.ip_address
    end
124817
def _repo_url_to_path(self, repo):
        """"""
        repo = repo.replace('http://', '')
        repo = repo.replace('https://', '')
        repo = repo.replace('/', '_')

        return os.sep.join([self._data_directory, repo])
628863
def _construct_url(self, endpoint):
        """"""
        parsed_url = urlparse(self.host)
        scheme = parsed_url[0]
        host = parsed_url[1]
        # Handle host without a scheme specified (eg. www.example.com)
        if scheme == "":
            scheme = "http"
            host = self.host

        if not endpoint.startswith("/"):
            endpoint = "/" + endpoint
        if self.config["api_version"] is not None:
            endpoint = "/v%d%s" % (self.config["api_version"], endpoint)
        return urlunparse((scheme, host, endpoint, '', '', ''))
761252
def url(self, request=""):
        """"""
        if request.startswith("/"):
            request = request[1:]
        return "{}://{}/{}".format(self.scheme, self.host, request)
47258
def urljoin(netloc, port, ssl):
    

    rv = ("https" if ssl else "http") + "://" + netloc
    if ssl and port != 443 or not ssl and port != 80:
        rv += ":%i" % port
    return rv
459355
def splithost(url):
    """"""
    global _hostprog
    if _hostprog is None:
        import re
        _hostprog = re.compile('^//([^/?]*)(.*)$')

    match = _hostprog.match(url)
    if match:
        host_port = match.group(1)
        path = match.group(2)
        if path and not path.startswith('/'):
            path = '/' + path
        return host_port, path
    return None, url