X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWebResponse.php;h=f977c205aa6fff6cc8748eb6d5e92e233a01998f;hb=18aab5e39503837c858f7d38992d067b644983a4;hp=adccf9c7da279624816002b183b1cb71a1f32df0;hpb=ea7c8b6f8babba9aaed733524ad886efea907c02;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebResponse.php b/includes/WebResponse.php index adccf9c7da..f977c205aa 100644 --- a/includes/WebResponse.php +++ b/includes/WebResponse.php @@ -37,6 +37,22 @@ class WebResponse { header( $string, $replace, $http_response_code ); } + /** + * Get a response header + * @param string $key The name of the header to get (case insensitive). + * @return string|null The header value (if set); null otherwise. + * @since 1.25 + */ + public function getHeader( $key ) { + foreach ( headers_list() as $header ) { + list( $name, $val ) = explode( ':', $header, 2 ); + if ( !strcasecmp( $name, $key ) ) { + return trim( $val ); + } + } + return null; + } + /** * Set the browser cookie * @param string $name Name of cookie @@ -51,7 +67,7 @@ class WebResponse { * secure: bool, secure attribute ($wgCookieSecure) * httpOnly: bool, httpOnly attribute ($wgCookieHttpOnly) * raw: bool, if true uses PHP's setrawcookie() instead of setcookie() - * For backwards compatability, if $options is not an array then it and + * For backwards compatibility, if $options is not an array then it and * the following two parameters will be interpreted as values for * 'prefix', 'domain', and 'secure' * @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options @@ -61,7 +77,7 @@ class WebResponse { global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly; if ( !is_array( $options ) ) { - // Backwards compatability + // Backwards compatibility $options = array( 'prefix' => $options ); if ( func_num_args() >= 5 ) { $options['domain'] = func_get_arg( 4 ); @@ -89,7 +105,7 @@ class WebResponse { $func = $options['raw'] ? 'setrawcookie' : 'setcookie'; - if ( wfRunHooks( 'WebResponseSetCookie', array( &$name, &$value, &$expire, $options ) ) ) { + if ( Hooks::run( 'WebResponseSetCookie', array( &$name, &$value, &$expire, $options ) ) ) { wfDebugLog( 'cookie', $func . ': "' . implode( '", "', array( @@ -150,7 +166,7 @@ class FauxResponse extends WebResponse { * @param string $key The name of the header to get (case insensitive). * @return string */ - public function getheader( $key ) { + public function getHeader( $key ) { $key = strtoupper( $key ); if ( isset( $this->headers[$key] ) ) {