]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/WebResponse.php
MediaWiki 1.17.0
[autoinstallsdev/mediawiki.git] / includes / WebResponse.php
index 09d373850fc7d378c5bfef8a4cf8a7242af1a332..2b1ec04cb9b65d733583163f56dea9a8e6a4c081 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+/**
+ * Classes used to send headers and cookies back to the user
+ *
+ * @file
+ */
+
 /**
  * Allow programs to request this object from WebRequest::response()
  * and handle all outputting (or lack of outputting) via it.
@@ -6,7 +12,7 @@
  */
 class WebResponse {
 
-       /** 
+       /**
         * Output a HTTP header, wrapper for PHP's
         * header()
         * @param $string String: header to output
@@ -58,3 +64,31 @@ class WebResponse {
                }
        }
 }
+
+
+class FauxResponse extends WebResponse {
+       private $headers;
+       private $cookies;
+
+       public function header($string, $replace=true) {
+               list($key, $val) = explode(":", $string, 2);
+
+               if($replace || !isset($this->headers[$key])) {
+                       $this->headers[$key] = $val;
+               }
+       }
+
+       public function getheader($key) {
+               return $this->headers[$key];
+       }
+
+       public function setcookie( $name, $value, $expire = 0 ) {
+               $this->cookies[$name] = $value;
+       }
+
+       public function getcookie( $name )  {
+               if ( isset($this->cookies[$name]) ) {
+                       return $this->cookies[$name];
+               }
+       }
+}
\ No newline at end of file