PerlDancer / Dancer

The easiest way to write web applications with Perl (Perl web micro-framework)
http://perldancer.org/
737 stars 209 forks source link

Use of send_file() prohibits any more updates to the user's cookie #886

Open DrHyde opened 11 years ago

DrHyde commented 11 years ago

Ideally, I'd like to see send_file()'s actions postponed until after all hooks have run, but failing that, the doco should be updated to note that anything that may cause the user's cookie to change, including any changes to their session() can't be done after send_file()

racke commented 10 years ago

This is annoying and session() doesn't really change the cookie at this point. Also you cannot find out from response object if a send_file call happened.

racke commented 10 years ago

We did the following workaround in our code:

hook after => sub {
     if (status == 200) {
+        return if var('no_session');
         log_page(request->path);
     }
 };

+hook after_file_render => sub {
+    my $res = shift;
+    var no_session => 1;
+};
+