Esempio n. 1
0
def start_servers(host, ports, paths, routes, bind_address, config, **kwargs):
    servers = defaultdict(list)
    for scheme, ports in ports.items():
        assert len(ports) == {"http": 2}.get(scheme, 1)

        # If trying to start HTTP/2.0 server, check compatibility
        if scheme == 'h2' and not http2_compatible():
            logger.error('Cannot start HTTP/2.0 server as the environment is not compatible. ' +
                         'Requires Python 2.7.10+ (< 3.0) and OpenSSL 1.0.2+')
            continue

        for port in ports:
            if port is None:
                continue
            init_func = {"http": start_http_server,
                         "https": start_https_server,
                         "h2": start_http2_server,
                         "ws": start_ws_server,
                         "wss": start_wss_server}[scheme]

            server_proc = ServerProc(scheme=scheme)
            server_proc.start(init_func, host, port, paths, routes, bind_address,
                              config, **kwargs)
            servers[scheme].append((port, server_proc))

    return servers
Esempio n. 2
0
def start_servers(host, ports, paths, routes, bind_address, config, **kwargs):
    servers = defaultdict(list)
    for scheme, ports in ports.items():
        assert len(ports) == {"http": 2}.get(scheme, 1)

        # TODO Not very ideal, look into removing it in the future
        # Check that python 2.7.15 is being used for HTTP/2.0
        if scheme == 'http2' and not http2_compatible():
            continue

        for port in ports:
            if port is None:
                continue
            init_func = {
                "http": start_http_server,
                "https": start_https_server,
                "http2": start_http2_server,
                "ws": start_ws_server,
                "wss": start_wss_server
            }[scheme]

            server_proc = ServerProc()
            server_proc.start(init_func, host, port, paths, routes,
                              bind_address, config, **kwargs)
            servers[scheme].append((port, server_proc))

    return servers
Esempio n. 3
0
def start_servers(host, ports, paths, routes, bind_address, config, **kwargs):
    servers = defaultdict(list)
    for scheme, ports in ports.items():
        assert len(ports) == {"http":2}.get(scheme, 1)

        # If trying to start HTTP/2.0 server, check compatibility
        if scheme == 'http2' and not http2_compatible():
            logger.error('Cannot start HTTP/2.0 server as the environment is not compatible. ' +
                         'Requires Python 2.7.10+ (< 3.0) and OpenSSL 1.0.2+')
            continue

        for port in ports:
            if port is None:
                continue
            init_func = {"http":start_http_server,
                         "https":start_https_server,
                         "http2":start_http2_server,
                         "ws":start_ws_server,
                         "wss":start_wss_server}[scheme]

            server_proc = ServerProc(scheme=scheme)
            server_proc.start(init_func, host, port, paths, routes, bind_address,
                              config, **kwargs)
            servers[scheme].append((port, server_proc))

    return servers
Esempio n. 4
0
def start_servers(host, ports, paths, routes, bind_address, config, **kwargs):
    servers = defaultdict(list)
    for scheme, ports in ports.items():
        assert len(ports) == {"http":2}.get(scheme, 1)

        # TODO Not very ideal, look into removing it in the future
        # Check that python 2.7.15 is being used for HTTP/2.0
        if scheme == 'http2' and not http2_compatible():
            continue

        for port in ports:
            if port is None:
                continue
            init_func = {"http":start_http_server,
                         "https":start_https_server,
                         "http2":start_http2_server,
                         "ws":start_ws_server,
                         "wss":start_wss_server}[scheme]

            server_proc = ServerProc()
            server_proc.start(init_func, host, port, paths, routes, bind_address,
                              config, **kwargs)
            servers[scheme].append((port, server_proc))

    return servers
Esempio n. 5
0
def start_servers(logger, host, ports, paths, routes, bind_address, config,
                  mp_context, log_handlers, **kwargs):
    servers = defaultdict(list)
    for scheme, ports in ports.items():
        assert len(ports) == {"http": 2, "https": 2}.get(scheme, 1)

        # If trying to start HTTP/2.0 server, check compatibility
        if scheme == 'h2' and not http2_compatible():
            logger.error(
                'Cannot start HTTP/2.0 server as the environment is not compatible. '
                + 'Requires OpenSSL 1.0.2+')
            continue

        # Skip WebTransport over HTTP/3 server unless if is enabled explicitly.
        if scheme == 'webtransport-h3' and not kwargs.get("webtransport_h3"):
            continue

        for port in ports:
            if port is None:
                continue

            init_func = {
                "http": start_http_server,
                "http-private": start_http_server,
                "http-public": start_http_server,
                "https": start_https_server,
                "https-private": start_https_server,
                "https-public": start_https_server,
                "h2": start_http2_server,
                "ws": start_ws_server,
                "wss": start_wss_server,
                "webtransport-h3": start_webtransport_h3_server,
            }[scheme]

            server_proc = ServerProc(mp_context, scheme=scheme)
            server_proc.start(init_func, host, port, paths, routes,
                              bind_address, config, log_handlers, **kwargs)
            servers[scheme].append((port, server_proc))

    return servers