summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY2
-rw-r--r--framework/Web/THttpResponse.php17
2 files changed, 14 insertions, 5 deletions
diff --git a/HISTORY b/HISTORY
index a20dcbc6..f0c15677 100644
--- a/HISTORY
+++ b/HISTORY
@@ -9,7 +9,7 @@ BUG: Non-control components can now use expressions in their properties (Qiang)
BUG: TControl.Visible did not make use of overriden getVisible() (Qiang)
BUG: TWizard did not stop navigation upon a validation failure (Qiang)
ENH: TButton, TImageButton and TLinkButton now implement IButtonControl interface (Qiang)
-ENH: TResponse::writeFile takes two additional parameters to allow sending memory data (Qiang)
+ENH: TResponse::writeFile takes three additional parameters to allow sending memory data (Qiang)
ENH: TButtonColumn can now be a column of image buttons (Qiang)
CHG: Rewrote client-side javascript validators, check your client-side validation behaviour (Wei)
CHG: Updated the javascript Prototype library, a few utilties functions REMOVED, may break your existing javascript code. (Wei)
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\"");