Loading ...
Sorry, an error occurred while loading the content.

Re: setting http output filter priority?

Expand Messages
  • Geoffrey Young
    ... try PerlSetOutputFilter http://perl.apache.org/docs/2.0/user/handlers/filters.html#C_PerlSetOutputFilter_ HTH --Geoff
    Message 1 of 8 , Mar 31, 2005
    View Source
    • 0 Attachment
      > I've studied the MP2 docs (including the 3 books I have: mp Cookbook,
      > Lincoln Stein's and Stas Bekman's), but really can't find anything that
      > tells me precisely how to insert an MP2 filter with a specific AP_FTYPE_*.
      >
      > Here's a simple flow of what I'd like to have happen:
      >
      > 1 - mod_cache [got valid content in cache? If so, go to 4; if not, go to 2]
      > 2 - mod_proxy [fetch content from origin web]
      > 3 - mod_cache [content cacheable? If so, cache it locally]
      > 4 - *MY FILTER*
      > 5 - deflate
      >
      > How can I get MYFILTER inserted in just the right place? (And ideally it
      > doesn't require modifying Apache source code to change AP_FTYPE values
      > for mod_cache...!)

      try PerlSetOutputFilter

      http://perl.apache.org/docs/2.0/user/handlers/filters.html#C_PerlSetOutputFilter_

      HTH

      --Geoff
    • Jeff Ambrosino
      Thanks for the reply Geoff... that isn t quite the problem. Here s a further explanation that should better articulate it. I ve turned on debug on Apache,
      Message 2 of 8 , Apr 1 3:13 PM
      View Source
      • 0 Attachment
        Thanks for the reply Geoff... that isn't quite the problem. Here's a
        further explanation that should better articulate it.

        I've turned on debug on Apache, and this is what's currently happening
        when content is found in the cache:

        [Fri Apr 01 14:14:13 2005] [debug] mod_disk_cache.c(371): disk_cache:
        Recalled cached URL info header www.company.com/page.html?
        [Fri Apr 01 14:14:13 2005] [debug] mod_disk_cache.c(502): disk_cache:
        Recalled headers for URL www.company.com/page.html?
        [Fri Apr 01 14:14:13 2005] [error] --> MYFILTER called here... <--
        [Fri Apr 01 14:14:13 2005] [debug] mod_cache.c(220): cache: running
        CACHE_OUT filter
        [Fri Apr 01 14:14:13 2005] [debug] mod_cache.c(229): cache: serving /page.html
        --> where I *want* MYFILTER to go <--
        [Fri Apr 01 14:14:13 2005] [debug] mod_deflate.c(468): [client
        192.168.0.101] Zlib: Compressed 7233 to 2171 : URL /page.html
        [Fri Apr 01 14:14:13 2005] [debug] mod_headers.c(527): headers:
        ap_headers_output_filter()
        [Fri Apr 01 14:14:13 2005] [debug] mod_deflate.c(468): [client
        192.168.0.101] Zlib: Compressed 7233 to 2171 : URL /page.html

        See the problem? MYFILTER is getting inserted before the cache is serving up
        the content, but I really want it to go after (otherwise MYFILTER doesn't
        see the body content). Is there a way around this aside from
        modifying mod_cache?

        thanks,
        Jeff


        On Mar 31, 2005 8:11 PM, Geoffrey Young <geoff@...> wrote:
        >
        > > I've studied the MP2 docs (including the 3 books I have: mp Cookbook,
        > > Lincoln Stein's and Stas Bekman's), but really can't find anything that
        > > tells me precisely how to insert an MP2 filter with a specific AP_FTYPE_*.
        > >
        > > Here's a simple flow of what I'd like to have happen:
        > >
        > > 1 - mod_cache [got valid content in cache? If so, go to 4; if not, go to 2]
        > > 2 - mod_proxy [fetch content from origin web]
        > > 3 - mod_cache [content cacheable? If so, cache it locally]
        > > 4 - *MY FILTER*
        > > 5 - deflate
        > >
        > > How can I get MYFILTER inserted in just the right place? (And ideally it
        > > doesn't require modifying Apache source code to change AP_FTYPE values
        > > for mod_cache...!)
        >
        > try PerlSetOutputFilter
        >
        > http://perl.apache.org/docs/2.0/user/handlers/filters.html#C_PerlSetOutputFilter_
        >
        > HTH
        >
        > --Geoff
        >
      • Geoffrey Young
        ... at the moment, no - the hooking mechanism in apache just isn t designed for this type of thing. in apache 1.3 we could mess with the order in which
        Message 3 of 8 , Apr 1 4:02 PM
        View Source
        • 0 Attachment
          > See the problem? MYFILTER is getting inserted before the cache is serving up
          > the content, but I really want it to go after (otherwise MYFILTER doesn't
          > see the body content). Is there a way around this aside from
          > modifying mod_cache?

          at the moment, no - the hooking mechanism in apache just isn't designed for
          this type of thing. in apache 1.3 we could mess with the order in which
          modules ran, but not in 2.0.

          an alternative to modifying mod_cache would be to modify mod_perl. from the
          look of things, mod_cache needs to be in a specific place wrt other core
          modules, so it might be easier to just modify mod_perl. but that would
          affect the order of all perl filters, so...

          --Geoff
        • Jeff Ambrosino
          From looking at the code, it appears that I may need to modify mod_perl and either of mod_cache or mod_deflate: mod_perl.c - line ~839 ...
          Message 4 of 8 , Apr 1 7:12 PM
          View Source
          • 0 Attachment
            From looking at the code, it appears that I may need to modify
            mod_perl and either
            of mod_cache or mod_deflate:

            mod_perl.c - line ~839
            ----------------------------------
            ap_register_output_filter(MP_FILTER_REQUEST_OUTPUT_NAME,
            MP_FILTER_HANDLER(modperl_output_filter_handler),
            AP_FTYPE_RESOURCE); // <---------------

            mod_cache.c - line ~936
            ----------------------------------
            cache_save_filter_handle =
            ap_register_output_filter("CACHE_SAVE",
            cache_save_filter,
            NULL,
            AP_FTYPE_CONTENT_SET-1); // <---------------
            [...]
            cache_out_filter_handle =
            ap_register_output_filter("CACHE_OUT",
            cache_out_filter,
            NULL,
            AP_FTYPE_CONTENT_SET-1); // <---------------

            mod_deflate.c - line ~845
            ----------------------------------
            ap_register_output_filter(deflateFilterName, deflate_out_filter, NULL,
            AP_FTYPE_CONTENT_SET); // <---------------

            So, mod_perl.c could register as AP_FTYPE_CONTENT, and mod_deflate.c could
            register as AP_FTYPE_CONTENT_SET+1. I think this is the least invasive
            change to get
            things working... do you concur?

            thanks,
            Jeff


            On Apr 1, 2005 7:02 PM, Geoffrey Young <geoff@...> wrote:
            >
            > > See the problem? MYFILTER is getting inserted before the cache is serving up
            > > the content, but I really want it to go after (otherwise MYFILTER doesn't
            > > see the body content). Is there a way around this aside from
            > > modifying mod_cache?
            >
            > at the moment, no - the hooking mechanism in apache just isn't designed for
            > this type of thing. in apache 1.3 we could mess with the order in which
            > modules ran, but not in 2.0.
            >
            > an alternative to modifying mod_cache would be to modify mod_perl. from the
            > look of things, mod_cache needs to be in a specific place wrt other core
            > modules, so it might be easier to just modify mod_perl. but that would
            > affect the order of all perl filters, so...
            >
            > --Geoff
            >
          • Geoffrey Young
            ... off the top of my head that looks ok. I just hope it doesn t muck with any additional filters you may need later on. good luck :) --Geoff
            Message 5 of 8 , Apr 2 5:09 AM
            View Source
            • 0 Attachment
              > So, mod_perl.c could register as AP_FTYPE_CONTENT, and mod_deflate.c could
              > register as AP_FTYPE_CONTENT_SET+1. I think this is the least invasive
              > change to get
              > things working... do you concur?

              off the top of my head that looks ok. I just hope it doesn't muck with any
              additional filters you may need later on.

              good luck :)

              --Geoff
            • Jeff Ambrosino
              I m logging some closure to this one... I was able to get this to work by modifying the priorities of mod_perl/src/modules/perlmod_perl.c s http output filter
              Message 6 of 8 , Apr 7 12:32 PM
              View Source
              • 0 Attachment
                I'm logging some closure to this one... I was able to get this to
                work by modifying the priorities of
                mod_perl/src/modules/perlmod_perl.c's http output filter to
                AP_FTYPE_CONTENT_SET-1, and then
                httpd-2.0.53/modules/experimental/mod_cache.c's cache_save and
                cache_out filter to AP_FTYPE_CONTENT_SET-2. Everything works! :)

                Note this change impacts all mod_perl apps running on your system.
                There are no other conflicts with Apache's built-in handlers and
                filters that I could see, although that could change in the future. I
                also think it might be a useful feature to be able to set mod_perl's
                filter priority either programmatically, or at least as a compile-time
                option.

                thanks
                Jeff


                On Apr 2, 2005 9:09 AM, Geoffrey Young <geoff@...> wrote:
                >
                > > So, mod_perl.c could register as AP_FTYPE_CONTENT, and mod_deflate.c could
                > > register as AP_FTYPE_CONTENT_SET+1. I think this is the least invasive
                > > change to get
                > > things working... do you concur?
                >
                > off the top of my head that looks ok. I just hope it doesn't muck with any
                > additional filters you may need later on.
                >
                > good luck :)
                >
                > --Geoff
                >
              • Geoffrey Young
                ... yes, we ve discussed both of these options on the dev list, so you can check the archives for all the issues (look for something about dynamic hook
                Message 7 of 8 , Apr 7 1:17 PM
                View Source
                • 0 Attachment
                  Jeff Ambrosino wrote:
                  > I
                  > also think it might be a useful feature to be able to set mod_perl's
                  > filter priority either programmatically, or at least as a compile-time
                  > option.

                  yes, we've discussed both of these options on the dev list, so you can check
                  the archives for all the issues (look for something about dynamic hook
                  ordering on dev@ and httpd-dev@...). basically, for it to work
                  dynamically across all platforms we need some changes in httpd, so you
                  wouldn't get that in 2.0 for sure. and I'm not sure that compile-time
                  options are the best recourse.

                  but I feel your pain - the entire hooking mechanism leaves knowing users
                  without a "shuffle" option, and that isn't very nice.

                  --Geoff
                Your message has been successfully submitted and would be delivered to recipients shortly.