summaryrefslogtreecommitdiff
path: root/includes/libs/HttpStatus.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /includes/libs/HttpStatus.php
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'includes/libs/HttpStatus.php')
-rw-r--r--includes/libs/HttpStatus.php28
1 files changed, 24 insertions, 4 deletions
diff --git a/includes/libs/HttpStatus.php b/includes/libs/HttpStatus.php
index 809bfdf5..442298a6 100644
--- a/includes/libs/HttpStatus.php
+++ b/includes/libs/HttpStatus.php
@@ -26,11 +26,10 @@
class HttpStatus {
/**
- * Get the message associated with HTTP response code $code
+ * Get the message associated with an HTTP response status code
*
- * @param $code Integer: status code
- * @return String or null: message or null if $code is not in the list of
- * messages
+ * @param int $code Status code
+ * @return string|null Message, or null if $code is not known
*/
public static function getMessage( $code ) {
static $statusMessage = array(
@@ -88,4 +87,25 @@ class HttpStatus {
return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null;
}
+ /**
+ * Output an HTTP status code header
+ *
+ * @since 1.26
+ * @param int $code Status code
+ */
+ public static function header( $code ) {
+ static $version = null;
+ $message = self::getMessage( $code );
+ if ( $message === null ) {
+ trigger_error( "Unknown HTTP status code $code", E_USER_WARNING );
+ return false;
+ }
+
+ if ( $version === null ) {
+ $version = isset( $_SERVER['SERVER_PROTOCOL'] ) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.0' ? '1.0' : '1.1';
+ }
+
+ header( "HTTP/$version $code $message" );
+ }
+
}