Use http_status() instead of homegrowing it. Adapt http_status to handle replies with data.
This commit is contained in:
parent
d11e80e1b3
commit
fabf7081d3
@ -320,6 +320,29 @@ function xml_status($st, $message = '') {
|
||||
killme();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send HTTP status header
|
||||
*
|
||||
* @param int $val
|
||||
* integer HTTP status result value
|
||||
* @param string $msg
|
||||
* optional message
|
||||
* @returns nil
|
||||
*/
|
||||
function http_status($val, $msg = '') {
|
||||
if ($val >= 400)
|
||||
$msg = (($msg) ? $msg : 'Error');
|
||||
if ($val >= 200 && $val < 300)
|
||||
$msg = (($msg) ? $msg : 'OK');
|
||||
|
||||
logger('http_status_exit ' . $val . ' ' . $msg);
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $val . ' ' . $msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send HTTP status header and exit.
|
||||
*
|
||||
@ -330,18 +353,12 @@ function xml_status($st, $message = '') {
|
||||
* @returns (does not return, process is terminated)
|
||||
*/
|
||||
function http_status_exit($val, $msg = '') {
|
||||
|
||||
if ($val >= 400)
|
||||
$msg = (($msg) ? $msg : 'Error');
|
||||
if ($val >= 200 && $val < 300)
|
||||
$msg = (($msg) ? $msg : 'OK');
|
||||
|
||||
logger('http_status_exit ' . $val . ' ' . $msg);
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $val . ' ' . $msg);
|
||||
http_status($val, $msg);
|
||||
killme();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert an XML document to a normalised, case-corrected array
|
||||
// used by webfinger
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?php /** @file */
|
||||
|
||||
require_once("include/network.php");
|
||||
|
||||
function system_down() {
|
||||
header('HTTP/1.0 503 Service Unavailable');
|
||||
http_status(503, 'Service Unavailable');
|
||||
echo <<< EOT
|
||||
<html>
|
||||
<head><title>System Unavailable</title></head>
|
||||
|
Reference in New Issue
Block a user