force_protocol

this function will force all host end points to have https protocol
If you are running CAS behind http, too bad for you
341535
function _protocol(url){
    // if the given url string doesn't include a protocol (e.g., http://)
    // assume it should be https://
    // if if does include http, then force it to be https

    // parseUrl will treat host:port as protocol:host, so we have to manually
    // add https string if it's not there
    if ( !url.match(/^http/) ) url = 'https://'+url;
    var urlp = parseUrl(url)
    var result = urlp.host === undefined || !urlp.host
               ? 'https://'+urlp.href
               : 'https://'+urlp.host
    // urlp.host takes care of funky ports too, but might not exist
    return result
}
318633
private static CloseableHttpClient wrapClient(String host) {

        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

        if (host.startsWith("https://")) {
            httpClient = sslClient();
        }

        return httpClient;
    }
26845
function (options) {
        if (!_.isObject(options)) {
            return;
        }

        var parsedUrl,
            port = _.get(options, 'port') >> 0;

        if (_.isString(options.host)) {
            parsedUrl = nodeUrl.parse(options.host);
            // we want to strip the protocol, but if protocol is not present then parsedUrl.hostname will be null
            this.host = parsedUrl.protocol ? parsedUrl.hostname : options.host;
        }

        _.isString(options.match) && (this.match = new UrlMatchPattern(options.match));
        _.isString(_.get(options, 'match.pattern')) && (this.match = new UrlMatchPattern(options.match.pattern));
        port && (this.port = port);
        _.isBoolean(options.tunnel) && (this.tunnel = options.tunnel);
        // todo: Add update method in parent class Property and call that here
        _.isBoolean(options.disabled) && (this.disabled = options.disabled);
        _.isBoolean(options.authenticate) && (this.authenticate = options.authenticate);
        _.isString(options.username) && (this.username = options.username);
        _.isString(options.password) && (this.password = options.password);
    }
1308911
function(httpServer) {
      this.stop();

      var port = isNaN(options.port) ? 3000 : +options.port;
      _httpServer = httpServer || http.createServer(function(req, res) {
        res.setHeader('Access-Control-Allow-Origin', '*');
        res.setHeader('Access-Control-Request-Method', '*');
        res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
        res.setHeader('Access-Control-Allow-Headers', '*');
        if ( req.method === 'OPTIONS' ) {
          res.writeHead(200);
          res.end();
          return;
        }
      });
      _httpServer.on('request', _handle);
      _httpServer.listen(port, function() {
        debug.log('Listening on '+port);
      });

      return _server;
    }
649658
def add_ssl_termination(self, loadbalancer, securePort, privatekey, certificate,
            intermediateCertificate, enabled=True, secureTrafficOnly=False):
        
        uri = "/loadbalancers/%s/ssltermination" % utils.get_id(loadbalancer)
        req_body = {"sslTermination": {
                "certificate": certificate,
                "enabled": enabled,
                "secureTrafficOnly": secureTrafficOnly,
                "privatekey": privatekey,
                "intermediateCertificate": intermediateCertificate,
                "securePort": securePort,
                }}
        resp, body = self.api.method_put(uri, body=req_body)
        return body
90096
protected function forceSsl()
    {
        // Define and trim base URL
        $baseUrl = trim($this->settings->sslRoutingBaseUrl);

        // Parse dynamic params in SSL routing URL
        if (mb_stripos($baseUrl, '{') !== false)
        {
            $baseUrl = Craft::$app->view->renderObjectTemplate(
                $this->settings->sslRoutingBaseUrl,
                $this->getDynamicParams()
            );
        }

        // Protect against invalid base URL
        if (empty($baseUrl) || $baseUrl == '/')
        {
            $baseUrl = trim(Craft::$app->request->hostInfo);
        }

        // Define and trim URI to append to the base URL
        $requestUri = trim(Craft::$app->request->getUrl());

        // Base URL should now be set to 'http://domain.ext' or 'http://domain.ext/'
        // Request URI can could be empty or '/page?key=val'

        // Define the final URL formed by the host portion and the URI portion
        $url = sprintf('%s%s', rtrim($baseUrl, '/'), $requestUri);

        // Ensure https is used
        $url = str_replace('http:', 'https:', $url);

        if (!filter_var($url, FILTER_VALIDATE_URL))
        {
            throw new ErrorException(
                Craft::t('patrol', '{url} is not a valid URL', ['url' => $url])
            );
        }

        Craft::$app->response->redirect(
            $url,
            $this->settings->redirectStatusCode
        );
    }
517738
def __need_ssl(self, host_and_port=None):
        
        if not host_and_port:
            host_and_port = self.current_host_and_port

        return host_and_port in self.__ssl_params
472836
def tls(force=False):
    
    def middleware(conn):
        if force or conn.has_extn('STARTTLS'):
            conn.starttls()
            conn.ehlo()
    return middleware
884156
public function forceAuthentication()
    {
        phpCAS::traceBegin();

        if ( $this->isAuthenticated() ) {
            // the user is authenticated, nothing to be done.
            phpCAS::trace('no need to authenticate');
            $res = true;
        } else {
            // the user is not authenticated, redirect to the CAS server
            if (isset($_SESSION['phpCAS']['auth_checked'])) {
                unset($_SESSION['phpCAS']['auth_checked']);
            }
            $this->redirectToCas(false/* no gateway */);
            // never reached
            $res = false;
        }
        phpCAS::traceEnd($res);
        return $res;
    }
1343526
public void setHttpsProxy(String host) {
    setProxyValue(HTTPS_SERVER, host);
    setProxyValue(USE_HTTPS, host != null);
  }
788643
def authorize_endpoint(params = nil)
      params = params.select { |_, v| !v.nil? } if params.respond_to? :select
      if params.nil? || params.empty?
        URI::HTTPS.build(host: @host, path: '/' + @tenant + AUTHORIZE_PATH)
      else
        URI::HTTPS.build(host: @host,
                         path: '/' + @tenant + AUTHORIZE_PATH,
                         query: URI.encode_www_form(params))
      end
    end
531564
def get_cas_client(service_url=None, request=None):
    
    # Handle CAS_SERVER_URL without protocol and hostname
    server_url = django_settings.CAS_SERVER_URL
    if server_url and request and server_url.startswith('/'):
        scheme = request.META.get("X-Forwarded-Proto", request.scheme)
        server_url = scheme + "://" + request.META['HTTP_HOST'] + server_url
    # assert server_url.startswith('http'), "settings.CAS_SERVER_URL invalid"

    if not django_settings.CAS_VERIFY_SSL_CERTIFICATE:
        warnings.warn(
            "`CAS_VERIFY_SSL_CERTIFICATE` is disabled, meaning that SSL certificates "
            "are not being verified by a certificate authority. This can expose your "
            "system to various attacks and should _never_ be disabled in a production "
            "environment."
        )

    return CASClient(
        service_url=service_url,
        version=django_settings.CAS_VERSION,
        server_url=server_url,
        extra_login_params=django_settings.CAS_EXTRA_LOGIN_PARAMS,
        renew=django_settings.CAS_RENEW,
        username_attribute=django_settings.CAS_USERNAME_ATTRIBUTE,
        proxy_callback=django_settings.CAS_PROXY_CALLBACK,
        verify_ssl_certificate=django_settings.CAS_VERIFY_SSL_CERTIFICATE
    )
563444
def should_strip_auth(self, old_url, new_url):
        """"""
        old_parsed = urlparse(old_url)
        new_parsed = urlparse(new_url)
        if old_parsed.hostname != new_parsed.hostname:
            return True
        # Special case: allow http -> https redirect when using the standard
        # ports. This isn't specified by RFC 7235, but is kept to avoid
        # breaking backwards compatibility with older versions of requests
        # that allowed any redirects on the same host.
        if (old_parsed.scheme == 'http' and old_parsed.port in (80, None)
                and new_parsed.scheme == 'https' and new_parsed.port in (443, None)):
            return False

        # Handle default port usage corresponding to scheme.
        changed_port = old_parsed.port != new_parsed.port
        changed_scheme = old_parsed.scheme != new_parsed.scheme
        default_port = (DEFAULT_PORTS.get(old_parsed.scheme, None), None)
        if (not changed_scheme and old_parsed.port in default_port
                and new_parsed.port in default_port):
            return False

        # Standard case: root URI must match
        return changed_port or changed_scheme
1112648
def build_url_base(host, port, is_https):
    
    base = "http"
    if is_https:
        base += 's'

    base += "://"
    base += host

    if port:
        base += ":"
        base += str(port)

    return base
898641
protected function _protocol() {
		$https = $this->_runtimeConfig['https'];
		if ($https === null) {
			$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
		}
		return $https ? 'https://' : '//';
	}
218071
function (req) {
                var protocol = req.secure ? 'https://' : 'http://',
                    hostname = req.headers.host,
                    originalUrl = req.originalUrl !== '/' ? req.originalUrl : '',
                    fullUrl = protocol + hostname + originalUrl,
                    // Split out the query string
                    urlParts = fullUrl.split('?'),
                    origin = urlParts[0],
                    search = urlParts[1] ? '?' + urlParts[1] : '';
                return {
                    // Protocol, hostname and port 
                    origin: origin,
                    // Query string
                    search: search,
                    protocol: protocol,
                    hostname: hostname,
                    href: originalUrl
                };
            }
1145256
def configure_proxy(proxy_setting, exceptions)
      ENV['HTTP_PROXY'] = proxy_setting
      ENV['http_proxy'] = proxy_setting
      ENV['HTTPS_PROXY'] = proxy_setting
      ENV['https_proxy'] = proxy_setting
      ENV['NO_PROXY'] = exceptions
      ENV['no_proxy'] = exceptions
      true
    end