}
/**
- * @param $name
+ * @param string $name The name of the header to get (case insensitive).
* @return bool|string
*/
public function getHeader( $name ) {
+ $name = strtoupper( $name );
return isset( $this->headers[$name] ) ? $this->headers[$name] : false;
}
* @param $val string
*/
public function setHeader( $name, $val ) {
+ $name = strtoupper( $name );
$this->headers[$name] = $val;
}
} else {
list( $key, $val ) = array_map( 'trim', explode( ":", $string, 2 ) );
+ $key = strtoupper( $key );
+
if ( $replace || !isset( $this->headers[$key] ) ) {
$this->headers[$key] = $val;
}
}
/**
- * @param $key string
+ * @param string $key The name of the header to get (case insensitive).
* @return string
*/
public function getheader( $key ) {
+ $key = strtoupper( $key );
+
if ( isset( $this->headers[$key] ) ) {
return $this->headers[$key];
}
--- /dev/null
+<?php
+
+class FauxRequestTest extends MediaWikiTestCase {
+
+ function testGetSetHeader() {
+ $value = 'test/test';
+
+ $request = new FauxRequest();
+ $request->setHeader( 'Content-Type', $value );
+
+ $this->assertEquals( $request->getHeader( 'Content-Type' ), $value );
+ $this->assertEquals( $request->getHeader( 'CONTENT-TYPE' ), $value );
+ $this->assertEquals( $request->getHeader( 'content-type' ), $value );
+ }
+}
$this->response->header( 'Location: http://127.0.0.2/', false );
$this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header with override disabled' );
+
+ $this->response->header( 'Location: http://localhost/' );
+ $this->assertEquals( 'http://localhost/', $this->response->getheader( 'LOCATION' ), 'Get header case insensitive' );
}
function testResponseCode() {