Page unavailable handler for use in frontend plugins from extensions.

@param string $reason Reason text
@param string $header HTTP header to send
@throws DocumentPreparationException
963016
public function pageUnavailableAndExit($reason = '', $header = '')
    {
        if (!defined('EXT_SOLR_INDEXING_CONTEXT')) {
            parent::pageUnavailableAndExit($reason, $header);
        }
        throw new DocumentPreparationException('Solr Document can not be prepared. The Reason: ' . $reason, 1517584040);
    }
1335544
public function getHeader($header)
    {
        $response = $this->getResponse();

        return $response->hasHeader($header) ? $response->getHeader($header)[0] : null;
    }
613968
public void addAllowedHeader(String header) {

		Constraint.ensureNotEmpty(header, String.format("Invalid header '%s'", header));
		allowedHeaders.add(header.toLowerCase());
	}
1201285
public function addHeaderToRequest($header, $value)
    {
        $this->request = $this->request->withHeader($header, $value);
    }
949729
protected function sendHeader($header, $content)
    {
        if (!headers_sent() && self::$sendHeaders) {
            header(sprintf('%s: %s', $header, $content));
        }
    }
402257
public void addExposedHeader(String header) {

		Constraint.ensureNotEmpty(header, String.format("Invalid header '%s'", header));
		exposedHeaders.add(header);
	}
64073
public function getHeader($header)
    {
        return isset($this->headers[$header]) ? $this->headers[$header] : null;
    }
468173
public function getResponseHeader($header)
        {
            if (! isset($this->responseHeaders[$header])) {
                throw new \InvalidArgumentException('Header does not exist');
            }

            return $this->responseHeaders[$header];
        }
242547
public static function getRedirectURLFromHeader(&$header)
  {
    // Get redirect-link from header
    preg_match("/((?i)location:|content-location:)(.{0,})[\n]/", $header, $match);
    
    if (isset($match[2]))
    {
      $redirect = trim($match[2]);
      return $redirect;
    }
    else return null;
  }
1023697
protected function handleMissingVar(File $phpCsFile, int $docBlockEndIndex, int $docBlockStartIndex, ?string $defaultValueType): void
    {
        $error = 'Doc Block annotation @var for variable missing';
        if ($defaultValueType === null) {
            $phpCsFile->addError($error, $docBlockEndIndex, 'VarAnnotationMissing');
            return;
        }

        $error .= ', type `' . $defaultValueType . '` detected';
        $fix = $phpCsFile->addFixableError($error, $docBlockEndIndex, 'WrongType');
        if (!$fix) {
            return;
        }

        $index = $phpCsFile->findPrevious(Tokens::$emptyTokens, $docBlockEndIndex - 1, $docBlockStartIndex, true);
        if (!$index) {
            $index = $docBlockStartIndex;
        }

        $phpCsFile->fixer->beginChangeset();
        $phpCsFile->fixer->addNewline($index);
        $phpCsFile->fixer->addContent($index, "\t" . ' * @var ' . $defaultValueType);
        $phpCsFile->fixer->endChangeset();
    }
285641
private function halt(string $status, string $reason): void
    {
        header('HTTP/1.0 '. $status);
        header('Connection: close');
        header('Content-Type: none');

        $xHaltMessage = sprintf('X-Halt: Reason=%s, Ip=%s, Url:%s', $reason,
            Util::getClientIp(), Util::getCurrentUrl());

        header($xHaltMessage);
        header_remove('X-Powered-By');

        $this->logger->logFail(new AppException($xHaltMessage));

        print '<!---->';

        exit(1); // boom!
    }
1185264
public function onPostSerialize(ObjectEvent $event)
    {
        /** @var RedirectTypeBehavior $document */
        $document = $event->getObject();

        if (!$document instanceof RedirectTypeBehavior) {
            return;
        }

        $visitor = $event->getVisitor();

        $redirectType = $document->getRedirectType();

        if (RedirectType::INTERNAL == $redirectType && null !== $document->getRedirectTarget()) {
            $visitor->addData('linked', 'internal');
            $visitor->addData('internal_link', $document->getRedirectTarget()->getUuid());
        } elseif (RedirectType::EXTERNAL == $redirectType) {
            $visitor->addData('linked', 'external');
            $visitor->addData('external', $document->getRedirectExternal());
        } else {
            $visitor->addData('linked', null);
        }
    }
811560
static public function conditional_header($url, $permRedir=FALSE) {
		if(count(func_get_args())==3) {
			self::debug_print(func_get_args(),1);
			throw new InvalidArgumentException("the 'exitAfter' argument is no longer valid");
		}
		
		if(isset($_SESSION) && is_array($_SESSION)) {
			//do some things to help protect against recursive redirects.
			if(isset($_SESSION['__conditional_header__'])) {
				$number = $_SESSION['__conditional_header__']['number'];
				$lastTime = $_SESSION['__conditional_header__']['last_time'];
				$timeSinceLast = microtime(true) - $lastTime;
				if(($timeSinceLast) <= 0.005 && $number > 5) {
					unset($_SESSION['__conditional_header__']);
					throw new Exception(__METHOD__ .": too many redirects (". $number .") in a short time (". $timeSinceLast ."), last url: (". $url .")");
				}
				else {
					$_SESSION['__conditional_header__']['number']++;
					$_SESSION['__conditional_header__']['last_time'] = microtime(true);
				}
			}
			else {
				$_SESSION['__conditional_header__'] = array(
					'last_time'	=> microtime(true),
					'number'		=> 0
				);
			}
		}
		
		if(!strlen($url)) {
			throw new InvalidArgumentException(__METHOD__ .": failed to specify URL (". $url .")");
		}
		else {
			if(headers_sent()) {
				//headers sent.  Use the meta redirect.
				print "
				<HTML>
				<HEAD>
				<TITLE>Redirect Page</TITLE>
				<META HTTP-EQUIV='refresh' content='0; URL=$url'>
				</HEAD>
				<a href=\"$url\"></a>
				</HTML>
				";
			}
			else {
				if($permRedir) {
					//NOTE: can't do much for permanent redirects if headers have already been sent.
					header("HTTP/1.1 301 Moved Permanently");
				}
				header("location:$url");
			}
		}
	}
459440
function renderHeader(&$header)
    {
        $name = $header->getName();
        $id = empty($name) ? '' : ' id="' . $name . '"';
        if (is_null($header->_text)) {
            $header_html = '';
        }
        elseif (!empty($name) && isset($this->_templates[$name])) {
            $header_html = str_replace('{header}', $header->toHtml(), $this->_templates[$name]);
        } else {
            $header_html = str_replace('{header}', $header->toHtml(), $this->_headerTemplate);
        }
        if ($this->_fieldsetsOpen > 0) {
            $this->_html .= $this->_closeFieldsetTemplate;
            $this->_fieldsetsOpen--;
        }
        $openFieldsetTemplate = str_replace('{id}', $id, $this->_openFieldsetTemplate);
        $this->_html .= $openFieldsetTemplate . $header_html;
        $this->_fieldsetsOpen++;
    }
75788
public function getHeader($header)
    {
        return isset($this->getHeaders()[$header]) ? $this->getHeaders()[$header] : null;
    }
288746
public function invokeLifecycleCallbacks(string $event, object $document, ?array $arguments = null) : void
    {
        if (! $document instanceof $this->name) {
            throw new InvalidArgumentException(sprintf('Expected document class "%s"; found: "%s"', $this->name, get_class($document)));
        }

        if (empty($this->lifecycleCallbacks[$event])) {
            return;
        }

        foreach ($this->lifecycleCallbacks[$event] as $callback) {
            if ($arguments !== null) {
                $document->$callback(...$arguments);
            } else {
                $document->$callback();
            }
        }
    }
1061879
public function flag($reason = null)
    {
        $this->props['isValid'] = false;
        $this->classAdd($this->props['attribsContainer'], 'has-error');
        if ($this->attribs['type'] == 'file' && isset($this->form->currentValues[ $this->attribs['name'] ])) {
            $fileInfo = $this->form->currentValues[ $this->attribs['name'] ];
            \unlink($fileInfo['tmp_name']);
            unset($this->form->currentValues[ $this->attribs['name'] ]);
        }
        if (!\is_null($reason)) {
            $this->props['invalidReason'] = $reason;
        }
        return;
    }