X-Git-Url: https://git.heureux-cyclage.org/index.php?a=blobdiff_plain;f=includes%2FWebResponse.php;h=f977c205aa6fff6cc8748eb6d5e92e233a01998f;hb=ff05579d1c7fcf9d449bdd474b48338dd58b1c5d;hp=ad9f4e664c9d8e7754ea102d530256a5d99f2a3d;hpb=92e31275a4f7117a4465b8886dfeca6dcb37351e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebResponse.php b/includes/WebResponse.php index ad9f4e664c..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 @@ -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] ) ) {