From 5ba6cd4be568f686d890835a77586077cde1a943 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 25 Apr 2006 01:31:43 +0000 Subject: Merge from 3.0 branch till 967. --- framework/Web/THttpResponse.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'framework/Web/THttpResponse.php') 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\""); -- cgit v1.2.3