Returns the referring URL for this request.

@param string|array|null $default Default URL to use if HTTP_REFERER cannot be read from headers
@param bool $local If true, restrict referring URLs to local server
@return string Referring URL
540990
public function referer($default = null, $local = false)
    {
        if (!$this->request) {
            return Router::url($default, !$local);
        }

        $referer = $this->request->referer($local);
        if ($referer === '/' && $default && $default !== $referer) {
            $url = Router::url($default, !$local);
            $base = $this->request->getAttribute('base');
            if ($local && $base && strpos($url, $base) === 0) {
                $url = substr($url, strlen($base));
                if ($url[0] !== '/') {
                    $url = '/' . $url;
                }

                return $url;
            }

            return $url;
        }

        return $referer;
    }
143390
protected function param($local, $name)
    {
        return isset($local[$name]) ? $local[$name] : (isset($this->defaults[$name]) ? $this->defaults[$name] : null);
    }
410961
public function getServerParam($name, $default = null)
    {
        $params = $this->getServerParams();
        if (!isset($params[$name])) {
            return $default;
        }
        return $params[$name];
    }
264659
public function getReferenceByUrl($url, $locale)
    {
        // Find the ref id for an url/locale
        $refId = $this->repository->findRefIdByUrl($url, $locale);
        if (!$refId) {
            return;
        }
        // Get the reference
        $ref = $this->repository->findById($refId);
        // Transform the reference into a viewReference
        $transformer = $this->transformer->getViewReferenceTransformer(
            (string) $ref['viewNamespace'], 'array'
        );

        return $transformer->transform($ref);
    }
346343
public static function get_realCurrentUrl()
    {
        $pageURL = 'http';
        if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
            $pageURL .= "s";
        }
        $pageURL .= "://".$_SERVER["SERVER_NAME"];
        if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= ':' . $_SERVER["SERVER_PORT"];
        }
        $pageURL .= $_SERVER["REQUEST_URI"];
        return $pageURL;
    }
374728
public static function referBool($name, $default = null)
    {
        $res = self::getReferParams($name);
        if (!is_null($res)) return self::parseInputToBool($res);
        return (is_null($default) ? null : ((bool)$default));
    }
428774
public function getHeader($name, $default = null)
    {
        $context = $this->_context;

        return isset($context->headers[$name]) ? $context->headers[$name] : $default;
    }
870426
public function getHeader(string $name, string $default = ''): string
    {
        switch ($this->type) {
            // Check the request is PSR-7 http message.
            case 'psr-7':
                return $this->request->getHeaderLine($name) ?: $default;

            // Check the is Laravel or Symfony.
            case 'laravel':
            case 'symfony':
                return $this->request->headers->get($name, $default);

            case 'thinkphp':
                return $this->request->header($name, $default);
        }

        // Not using framewoerk ?
        // Read global variable $_REQUEST.
        foreach ($this->request as $key => $value) {
            if (strtolower($key) === strtolower($name)) {
                return (string) $value;
            }
        }

        // return default line string.
        return $default;
    }
698496
private function returnLocalParam($localStorage, $variable, $default = false)
    {
        if (!empty($variable)) {
            if (isset($this->{$localStorage}[$variable])) {
                return $this->{$localStorage}[$variable];
            } else {
                return $default;
            }
        } else {
            return $this->{$localStorage};
        }
    }
37595
public function getUrl() : ?string 
    {
        if ( ! $this->hasUrl()) {
            $this->setUrl($this->getDefaultUrl());
        }
        return $this->url;
    }
1193613
public function getDescription($default = false)
    {
        if (($ob = $this->_headers['content-description']) &&
            strlen($ob->value)) {
            return $ob->value;
        }

        return $default
            ? $this->getName()
            : '';
    }
732158
public function getReferer() : ?Url
    {
        $referer = $this->getFirstHeader('Referer');

        if ($referer === null) {
            return null;
        }

        try {
            return new Url($referer);
        } catch (\InvalidArgumentException $e) {
            return null;
        }
    }
540074
protected function _refererRedirectUrl($default = null)
    {
        $controller = $this->_controller();

        return $this->_redirectUrl($controller->referer($default, true));
    }
945636
public function getHeader($name, $default = null)
    {
        if (empty($name)) {
            return $default;
        }

        $temp = 'HTTP_' . strtoupper(str_replace('-', '_', $name));
        if (isset($this->env[$temp])) {
            return $this->env[$temp];
        }

        if (function_exists('apache_request_headers')) {
            // @codeCoverageIgnoreStart
            $method = 'apache_request_headers';
            $headers = $method();
            if (isset($headers[$name])) {
                return $headers[$name];
            }
            $header = strtolower($name);
            foreach ($headers as $key => $value) {
                if (strtolower($key) == $name) {
                    return $value;
                }
            }
        }
        // @codeCoverageIgnoreEnd

        return $default;
    }
950142
public static function getSourceLocaleString(string $default = 'en-US'): string
    {
        $view = static::get('view', null, false);

        return $view ? (string)$view->getSourceLocale() : $default;
    }
839853
public function getCurrentDomain($default = null)
    {
        $currentDomain = PhpServer::getRequestDomain();

        //Use the default site if the requested domain name is an IP address
        $ipValidator = new Ip();
        if ($ipValidator->isValid($currentDomain)) {
            $currentDomain = $default;
        }

        return $currentDomain;
    }
652687
public static function referString($name, $default = null)
    {
        $res = self::getReferParams($name);
        if (!is_null($res)) return self::parseInputToString($res);
        return $default;
    }