function file() {
header('Content-Type: '.$this->mime_type);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this-
>last_modified).' GMT');
header('Cache-Control:');
header('Content-Disposition: inline; filename='.$this-
>file_name);
header('Pragma:');
return $this->fetchContent();
}
echo $file();
How can I return this using a k_*Response*?
class FileViewerComponent extends k_Component
{
protected $mime_type;
protected $last_modified;
protected $file_name;
function GET()
{
// how do one construct the response
return k_*Response*();
}
}
I am using GET() instead of renderHtml() as it must be more correct?
Do you agree?
Yes, certainly. You're not returning a html document for this component.
On Sat, Mar 6, 2010 at 7:03 PM, lsolesen <lsol...@gmail.com> wrote:
> How can I return this using a k_*Response*?
You can do:
class FileViewerComponent extends k_Component {
protected $mime_type;
protected $last_modified;
protected $file_name;
function GET() {
$response = new k_HttpResponse(200, $this->fetchContent());
$response->setHeader('Content-Type', $this->mime_type);
$response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s',
$this->last_modified).' GMT');
$response->setHeader('Cache-Control', 'private');
$response->setHeader('Content-Disposition', 'inline;
filename='.$this->file_name);
$response->setHeader('Pragma', 'cache');
$response->setContent();
return $response;
}
}
--
troels