3 * Classes used to send headers and cookies back to the user
9 * Allow programs to request this object from WebRequest::response()
10 * and handle all outputting (or lack of outputting) via it.
16 * Output a HTTP header, wrapper for PHP's
18 * @param $string String: header to output
19 * @param $replace Bool: replace current similar header
21 public function header($string, $replace=true) {
22 header($string,$replace);
25 /** Set the browser cookie
26 * @param $name String: name of cookie
27 * @param $value String: value to give cookie
28 * @param $expire Int: number of seconds til cookie expires
30 public function setcookie( $name, $value, $expire = 0 ) {
31 global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
32 global $wgCookieSecure,$wgCookieExpiration, $wgCookieHttpOnly;
34 $expire = time() +
$wgCookieExpiration;
36 $httpOnlySafe = wfHttpOnlySafe();
38 'setcookie: "' . implode( '", "',
40 $wgCookiePrefix . $name,
46 $httpOnlySafe && $wgCookieHttpOnly ) ) . '"' );
47 if( $httpOnlySafe && isset( $wgCookieHttpOnly ) ) {
48 setcookie( $wgCookiePrefix . $name,
56 // setcookie() fails on PHP 5.1 if you give it future-compat paramters.
58 setcookie( $wgCookiePrefix . $name,
69 class FauxResponse
extends WebResponse
{
73 public function header($string, $replace=true) {
74 list($key, $val) = explode(":", $string, 2);
76 if($replace ||
!isset($this->headers
[$key])) {
77 $this->headers
[$key] = $val;
81 public function getheader($key) {
82 return $this->headers
[$key];
85 public function setcookie( $name, $value, $expire = 0 ) {
86 $this->cookies
[$name] = $value;
89 public function getcookie( $name ) {
90 if ( isset($this->cookies
[$name]) ) {
91 return $this->cookies
[$name];