summaryrefslogtreecommitdiff
path: root/framework/Web/THttpResponse.php
diff options
context:
space:
mode:
authorxue <>2006-04-25 01:31:43 +0000
committerxue <>2006-04-25 01:31:43 +0000
commit5ba6cd4be568f686d890835a77586077cde1a943 (patch)
tree54138a79e147bcfb0f6833d2d284a2f825c18f2a /framework/Web/THttpResponse.php
parent1afc913c386bba8e6072c278b0eb4fd9818ab310 (diff)
Merge from 3.0 branch till 967.
Diffstat (limited to 'framework/Web/THttpResponse.php')
-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\"");