summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorxue <>2006-04-24 15:49:14 +0000
committerxue <>2006-04-24 15:49:14 +0000
commiteabb6bc07abdc5d74032d44661545bbda9d20bbe (patch)
tree080ba3b3244817abb714a3c637bbeff0ab3c9d9b /framework/Web
parentb181cd60a8fff5a94179f66fa1165952ed170a95 (diff)
THttpResponse.writeFile can now use customized headers.
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/THttpResponse.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index 29258259..261c34ed 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -222,9 +222,10 @@ class THttpResponse extends TModule implements ITextWriter
* @param string file name
* @param string content to be set. If null, the content will be read from the server file pointed to by $fileName.
* @param string mime type of the content.
+ * @param array list of headers to be sent
* @throws TInvalidDataValueException if the file cannot be found
*/
- public function writeFile($fileName,$content=null,$mimeType=null)
+ public function writeFile($fileName,$content=null,$mimeType=null,$headers=null)
{
static $defaultMimeTypes=array(
'css'=>'text/css',
@@ -249,9 +250,17 @@ class THttpResponse extends TModule implements ITextWriter
}
}
$fn=basename($fileName);
- header('Pragma: public');
- header('Expires: 0');
- header('Cache-Component: must-revalidate, post-check=0, pre-check=0');
+ if(is_array($headers))
+ {
+ foreach($headers as $h)
+ header($h);
+ }
+ else
+ {
+ header('Pragma: public');
+ header('Expires: 0');
+ header('Cache-Component: must-revalidate, post-check=0, pre-check=0');
+ }
header("Content-type: $mimeType");
header('Content-Length: '.($content===null?filesize($fileName):strlen($content)));
header("Content-Disposition: attachment; filename=\"$fn\"");