Get the scheme for a raw URL.

@param  bool|null  $secure
@return string
428768
protected function getSchemeForUrl($secure)
  {
    if (is_null($secure)) {
      if (is_null($this->cachedScheme)) {
          $this->cachedScheme = $this->plugin->make('request')->getScheme().'://';
      }

      return $this->cachedScheme;
    }

    return $secure ? 'https://' : 'http://';
  }
781603
public function urlWithParams($path = null, $qs = [], $secure = null)
    {
        $url = app('url')->to($path, $secure);
        if (count($qs)){
            foreach($qs as $key => $value){
                $qs[$key] = sprintf('%s=%s',$key, urlencode($value));
            }
            $url = sprintf('%s?%s', $url, implode('&', $qs));
        }
        return $url;
    }
916829
public function getGetUrl()
    {
        $scheme = empty($this->rowUrl["scheme"]) ? "http://" : $this->rowUrl["scheme"] . "://";
        $user   = empty($this->rowUrl["user"]) ? "" : $this->rowUrl["user"];
        $pass   = empty($this->rowUrl["pass"]) ? "" : $this->rowUrl["pass"];

        // if pass is there, put a : between user and pass (user:pass)
        if (!empty($pass)) {
            $user =  rawurlencode($user) .  ":";
        }

        // if user and password are there, put a @ after pass, so that user:pass@host will be constructed
        if (!empty($user) || !empty($pass)) {
            $pass = rawurlencode($pass) . "@";
        }

        $host = $this->rowUrl["host"];
        $port = empty($this->rowUrl["port"]) ? "" : ":" . $this->rowUrl["port"];

        $path = empty($this->rowUrl["path"]) ? "" : $this->rowUrl["path"];

        $urlquery = "";
        if (count($this->getParams) > 0)
        {
            $urlquery = "?" . http_build_query($this->getParams);
        }
        return $scheme . $user . $pass . $host . $port . $path . $urlquery;
    }
123466
public function getUrl()
    {
        $https = $this->isHTTPS();

        $protocol = strtolower($_SERVER["SERVER_PROTOCOL"]);
        $protocol = substr($protocol, 0, strpos($protocol, "/")) . ($https ? "s" : "");

        $port = $_SERVER["SERVER_PORT"];
        $port = ($port == 80 && !$https) || ($port == 443 && $https) ? "" : ":$port";

        $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : null;
        $host = $host ? $host : $_SERVER["SERVER_NAME"] . $port;

        return "$protocol://$host" . $_SERVER["REQUEST_URI"];
    }
114027
protected function getScheme()
    {
        if (isset($_SERVER['REQUEST_SCHEME'])) {
            $scheme = $_SERVER['REQUEST_SCHEME'];
        } else if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) {
            $scheme = 'https';
        } else {
            if ($_SERVER['SERVER_PORT'] == 443) {
                $scheme = 'https';
            } else {
                $scheme = 'http';
            }
        }
        
        return $scheme;
    }
46786
public function to($url, $extra = [], $secure = null)
    {
        if ($this->isValidUrl($url)) {
            return $url;
        }

        $scheme = $this->getScheme($secure);

        $params = $this->setParams($extra);

        $url = $this->setUrl($url);

        $url = $scheme.$url.$params;

        return self::locate($url);
    }
454748
public function link($url, $title = null, $attributes = array(), $secure = null)
	{
		$url = $this->url->to($url, array(), $secure);

		if (is_null($title) || $title === false) $title = $url;

		return '<a href="'.$url.'"'.$this->attributes($attributes).'>'.$this->entities($title).'</a>';
	}
132985
public function secure($secure = null)
    {
        if ($secure !== null) {
            $this->secure = (bool) $secure;
        }

        return (bool) $this->secure;
    }
660947
public function url($uri, $secure = null)
    {
        // If path is full, so we just return.
        if (preg_match('#^http|//:#', $uri))
        {
            return $uri;
        }

        $path = $this->getCurrentPath().$uri;

        if(substr($path, 0, 6)=='public') $path = substr($path, 7);

        return $this->configAssetUrl($path, $secure);
    }
1217473
public static function getUrl()
    {
        if (static::isCLI()) {
            return null;
        }

        if (static::$url === null) {
            $url = 'http';
            if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
                $url .= 's';
            }
            $url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
            static::$url = new Url($url);
        }

        return static::$url;
    }
1133051
public function intended($default = '/', $status = 302, $headers = array(), $secure = null)
    {
        $path = $this->session->pull('url.intended', $default);

        return $this->to($path, $status, $headers, $secure);
    }
229689
public String getSecureUrl() {

        if (m_secureServer != null) {
            return m_secureServer.getUrl();
        } else {
            LOG.warn(Messages.get().getBundle().key(Messages.ERR_SECURESERVER_MISSING_1, toString()));
            return getUrl();
        }
    }
1092020
function getCookiesForRequest($cookies, $secure=false) {
		$cookie_str = '';
		if ((! is_null($cookies)) && (is_array($cookies))) {
			foreach ($cookies as $cookie) {
				if (! is_array($cookie)) {
					continue;
				}
	    		$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
				if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
					if (strtotime($cookie['expires']) <= time()) {
						$this->debug('cookie has expired');
						continue;
					}
				}
				if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
					$domain = preg_quote($cookie['domain']);
					if (! preg_match("'.*$domain$'i", $this->host)) {
						$this->debug('cookie has different domain');
						continue;
					}
				}
				if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
					$path = preg_quote($cookie['path']);
					if (! preg_match("'^$path.*'i", $this->path)) {
						$this->debug('cookie is for a different path');
						continue;
					}
				}
				if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
					$this->debug('cookie is secure, transport is not');
					continue;
				}
				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
	    		$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
			}
		}
		return $cookie_str;
  }
993471
protected function getScheme($secure)
  {
    if (is_null($secure)) {
        return $this->forceSchema ?: $this->plugin->make('request')->getScheme().'://';
    }

    return $secure ? 'https://' : 'http://';
  }
901721
public function get_url($forcedownload=false, $https=false) {
        if (!$this->is_readable()) {
            return null;
        }

        if ($this->lf->is_directory()) {
            return null;
        }

        $filepath = $this->lf->get_filepath();
        $filename = $this->lf->get_filename();
        $courseid = $this->context->instanceid;

        $path = '/'.$courseid.$filepath.$filename;

        return file_encode_url($this->urlbase, $path, $forcedownload, $https);
    }
1283160
protected function getRootUrl($scheme, $root = null)
	{
		$root = $root ?: $this->request->root();

		$start = starts_with($root, 'http://') ? 'http://' : 'https://';

		return preg_replace('~'.$start.'~', $scheme, $root, 1);
	}
209710
private function getApiUrl()
    {
        $h = $this->secure === true ? 'https' : 'http';
        return sprintf('%s://%s/%s/', $h, $this->url, $this->version);
    }