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() && $wgCookieHttpOnly;
38 'setcookie: "' . implode( '", "',
40 $wgCookiePrefix . $name,
46 $httpOnlySafe ) ) . '"' );
47 setcookie( $wgCookiePrefix . $name,
58 class FauxResponse
extends WebResponse
{
62 public function header($string, $replace=true) {
63 list($key, $val) = explode(":", $string, 2);
65 if($replace ||
!isset($this->headers
[$key])) {
66 $this->headers
[$key] = $val;
70 public function getheader($key) {
71 return $this->headers
[$key];
74 public function setcookie( $name, $value, $expire = 0 ) {
75 $this->cookies
[$name] = $value;
78 public function getcookie( $name ) {
79 if ( isset($this->cookies
[$name]) ) {
80 return $this->cookies
[$name];