[Catalyst] Problem with RenderView

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Fri May 4 18:49:26 GMT 2007







Bernhard Graf <catalyst2 at augensalat.de> wrote on 05/04/2007 10:43:44 AM:
[...]
> Sorry. My description seemed to be a little misleading.
> With "stored to disc" I meant the client's disc
> (by adding this header your browser shows the "Save to disc" dialogue:
>  $c->res->header(
>   'Content-Disposition', qq[attachment; filename="$filename"]
>  );
> )
>
> Basically this is what happens:
> $c->stash(result_set => $c->model('Table'));   # dl the whole table
> $c->forward('MyApp::View::DBIC::CSV');
>
> and the view fetches row by row from $c->stash->{result_set}, formats,
> buffers and $c->write()s as soon the buffer has a certain size (16kB).

Gotcha, makes sense now -- I think this is what was driving many of the
false leads.

For the save to disk force prompt -- code I that has served me well in the
past (for all tested browsers, ie mac, ie 5->7, moz, ff 1->2, safari,
opera, lynx ...)
      $c->res->headers->content_type('application/octet-stream');
        $c->res->headers->content_length( $stat->size );
        $c->res->headers->last_modified( $stat->mtime );
        $c->response->headers->header(
            'Content-disposition:' => "attachment; filename=$filename" );
        $c->res->headers->expires( time() );
        $c->res->headers->header( 'Last-Modified' => HTTP::Date::time2str
);
        $c->res->headers->header( 'Pragma'        => 'no-cache' );
        $c->res->headers->header( 'Cache-Control' => 'no-cache' );


This forces the save promt and also makes sure no-cache is set so that a
failed download does not leave the user with a partial file.




-Wade





More information about the Catalyst mailing list