diff options
Diffstat (limited to 'framework/Web/THttpResponse.php')
-rw-r--r-- | framework/Web/THttpResponse.php | 17 |
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\"");
|