Merge "FauxRequest: Avoid header leak"
[lhc/web/wiklou.git] / includes / WebResponse.php
index 83ac51a..1b6947c 100644 (file)
@@ -28,7 +28,7 @@
 class WebResponse {
 
        /**
-        * Output a HTTP header, wrapper for PHP's header()
+        * Output an HTTP header, wrapper for PHP's header()
         * @param string $string Header to output
         * @param bool $replace Replace current similar header
         * @param null|int $http_response_code Forces the HTTP response code to the specified value.
@@ -53,6 +53,15 @@ class WebResponse {
                return null;
        }
 
+       /**
+        * Output an HTTP status code header
+        * @since 1.26
+        * @param int $code Status code
+        */
+       public function statusHeader( $code ) {
+               HttpStatus::header( $code );
+       }
+
        /**
         * Set the browser cookie
         * @param string $name The name of the cookie.
@@ -60,7 +69,7 @@ class WebResponse {
         * @param int|null $expire Unix timestamp (in seconds) when the cookie should expire.
         *        0 (the default) causes it to expire $wgCookieExpiration seconds from now.
         *        null causes it to be a session cookie.
-        * @param array|null $options Assoc of additional cookie options:
+        * @param array $options Assoc of additional cookie options:
         *     prefix: string, name prefix ($wgCookiePrefix)
         *     domain: string, cookie domain ($wgCookieDomain)
         *     path: string, cookie path ($wgCookiePath)
@@ -72,7 +81,7 @@ class WebResponse {
         *   'prefix', 'domain', and 'secure'
         * @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options
         */
-       public function setcookie( $name, $value, $expire = 0, $options = null ) {
+       public function setcookie( $name, $value, $expire = 0, $options = array() ) {
                global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
                global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly;
 
@@ -162,6 +171,14 @@ class FauxResponse extends WebResponse {
                }
        }
 
+       /**
+        * @since 1.26
+        * @param int $code Status code
+        */
+       public function statusHeader( $code ) {
+               $this->code = intval( $code );
+       }
+
        /**
         * @param string $key The name of the header to get (case insensitive).
         * @return string|null The header value (if set); null otherwise.
@@ -188,9 +205,9 @@ class FauxResponse extends WebResponse {
         * @param string $name The name of the cookie.
         * @param string $value The value to be stored in the cookie.
         * @param int|null $expire Ignored in this faux subclass.
-        * @param array|null $options Ignored in this faux subclass.
+        * @param array $options Ignored in this faux subclass.
         */
-       public function setcookie( $name, $value, $expire = 0, $options = null ) {
+       public function setcookie( $name, $value, $expire = 0, $options = array() ) {
                $this->cookies[$name] = $value;
        }