From: Ori Livneh Date: Fri, 7 Nov 2014 18:52:23 +0000 (-0800) Subject: Add WebResponse::getHeader() X-Git-Tag: 1.31.0-rc.0~13352^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=67e9b8e3946389c2797fa41eccbd439aab7e211d;p=lhc%2Fweb%2Fwiklou.git Add WebResponse::getHeader() Equivalent to FauxResponse::getHeader() Also change case of FauxResponse::getHeader. Change-Id: I569b2ebbcd166f5d0a5a5f2dfa913a6aa49e13f4 --- diff --git a/includes/WebResponse.php b/includes/WebResponse.php index ad9f4e664c..d39f884789 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 @@ -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] ) ) {