summaryrefslogtreecommitdiff
path: root/framework/Web/THttpResponse.php
diff options
context:
space:
mode:
authorknut <>2007-02-08 11:32:55 +0000
committerknut <>2007-02-08 11:32:55 +0000
commit4107da03448e33335e31951217d564b0246c0c6f (patch)
tree8efa503272c397ef13f962614f688592fb88b1d0 /framework/Web/THttpResponse.php
parentf9aea3417143297043dc812b8be9e9573ab0b64b (diff)
corrected configuration example
Diffstat (limited to 'framework/Web/THttpResponse.php')
-rw-r--r--framework/Web/THttpResponse.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index 46d1b4f5..bc8f590b 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -34,7 +34,7 @@ Prado::using('System.Web.THttpResponseAdapter');
*
* THttpResponse may be configured in application configuration file as follows
*
- * <module id="response" CacheExpire="20" CacheControl="nocache" BufferOutput="true" />
+ * <module id="response" class="System.Web.THttpResponse" CacheExpire="20" CacheControl="nocache" BufferOutput="true" />
*
* where {@link getCacheExpire CacheExpire}, {@link getCacheControl CacheControl}
* and {@link getBufferOutput BufferOutput} are optional properties of THttpResponse.
@@ -258,9 +258,10 @@ class THttpResponse extends TModule implements ITextWriter
* @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
+ * @param string alternative file name used in attachment disposition
* @throws TInvalidDataValueException if the file cannot be found
*/
- public function writeFile($fileName,$content=null,$mimeType=null,$headers=null)
+ public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$displayName=null)
{
static $defaultMimeTypes=array(
'css'=>'text/css',
@@ -284,7 +285,6 @@ class THttpResponse extends TModule implements ITextWriter
$mimeType=$defaultMimeTypes[$ext];
}
}
- $fn=basename($fileName);
if(is_array($headers))
{
foreach($headers as $h)
@@ -298,7 +298,10 @@ class THttpResponse extends TModule implements ITextWriter
}
header("Content-type: $mimeType");
header('Content-Length: '.($content===null?filesize($fileName):strlen($content)));
- header("Content-Disposition: attachment; filename=\"$fn\"");
+ if($displayName === null) {
+ $displayName = basename($fileName);
+ }
+ header("Content-Disposition: attachment; filename=\"$displayName\"");
header('Content-Transfer-Encoding: binary');
if($content===null)
readfile($fileName);