On Sun, Mar 22, 2009 at 09:23:49PM -0400, Philippe M. Chiasson wrote:
> On 22/3/09 15:25, Louis-David Mitterrand wrote:
> > Hi,
> > 
> > I noticed something interesting with mod_deflate when serving binary
> > content from a mason component:
> > 
> >     <%init>
> >     $m->clear_buffer();
> >     $r->content_type("video/mp4");
> >     $r->headers_out->add('Content-length' => -s $file);
> >     $r->sendfile($file);
> >     $m->abort(200);
> >     </%init>
> > 
> > mod_deflate is enabled with the default:
> > 
> >     AddOutputFilterByType DEFLATE text/html text/plain text/xml
> > 
> > and .md mason components have:
> > 
> >     AddType text/html .md
> > 
> > But when I change the content-type from within the component mod_deflate
> > doesn't seem to notice and keeps gzip'ing the video/mp4 output, which
> > FlowPlayer doesn't appreciate.
> > 
> > I certainly could disable mod_deflate and be on my merry way. 
> > 
> > But I thought I'd ask the modperl list (already posted to mason-users)
> > whether this mod_deflate behaviour is expected and/or normal?
> 
> Sounds like Mason runs exclusively in the PerlResponse phase, at which
> point, AddOutputFilterByType has already decided if it should apply the
> filter or not, so it's too late to change that.
> 
> One easy way to disable mod_deflate from that point in time, from mason,
> would be to do:
> 
> $r->subprocess_env('no-gzip' => 1);
> 
> Since from mod_deflate.c:
> 
>         /* some browsers might have problems, so set no-gzip
>          * (with browsermatch) for them
>          */
>         if (apr_table_get(r->subprocess_env, "no-gzip")) {
>             ap_remove_output_filter(f);
>             return ap_pass_brigade(f->next, bb);
>         }
> 
> Give it a try, this is untested!

And this works fine! Thank you.

Another possible (less robust) solution is to add this to deflate.conf:

        SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary

This only works if the $r->uri ends with .mp4 which in my case does
because I use an explicit $r->path_info:

/video.md/directory/file.mp4

"/directory/file.mp4" points to a directory hierarchy outside of the
ServerRoot.

Cheers,

-- 
http://www.critikart.net

Reply via email to