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

Activating/decativating PerlOutputFilterHandler "on-the-fly"

Expand Messages
  • Srebrenko Sehic
    Hi ppl, I have a couple of PerlOutputFilterHandler directives registered in my httpd.conf conigurations. Is there any way to activate/deactivate
    Message 1 of 3 , May 2, 2005
    • 0 Attachment
      Hi ppl,

      I have a couple of PerlOutputFilterHandler directives registered in my
      httpd.conf <VirtualHost> conigurations.

      Is there any way to activate/deactivate these filters without editing
      httpd.conf and restarting Apache?

      I'm running Apache 2.0.54 with mod_perl2_RC5.

      TIA,

      // haver
    • Jeff Ambrosino
      From within an existing Perl handler/filter, you can dynamically insert ( register ) a new filter with the add_output_filter method on the request object:
      Message 2 of 3 , May 2, 2005
      • 0 Attachment
        From within an existing Perl handler/filter, you can dynamically
        insert ('register') a new filter with the add_output_filter method on
        the request object:

        $r->add_output_filter(\&callback);

        And, you can remove a downstream filter (from within an upstream filter) with:

        $next_f = $f->next;
        $next_f->remove;

        ...or even any subsequent invocations of the current filter (i.e., for
        the current request) with:

        $f->remove;

        n.b. I'm not sure if it is possible to remove a downstream filter from
        within a handler, since it appears you need the $f (filter) object to
        do a remove... (can one reference the filter object from the request
        object?)

        For more explanation that will probably put you on the right track, see:
        http://perl.apache.org/docs/2.0/api/Apache/Filter.html

        cheers
        Jeff

        On 5/2/05, Srebrenko Sehic <haver@...> wrote:
        > Hi ppl,
        >
        > I have a couple of PerlOutputFilterHandler directives registered in my
        > httpd.conf <VirtualHost> conigurations.
        >
        > Is there any way to activate/deactivate these filters without editing
        > httpd.conf and restarting Apache?
        >
        > I'm running Apache 2.0.54 with mod_perl2_RC5.
        >
        > TIA,
        >
        > // haver
        >
      • Stas Bekman
        ... And you can also do that from the FilterInitHandler phase http://perl.apache.org/docs/2.0/user/handlers/filters.html#Filter_Initialization_Phase ... It s
        Message 3 of 3 , May 2, 2005
        • 0 Attachment
          Jeff Ambrosino wrote:
          >>From within an existing Perl handler/filter, you can dynamically
          > insert ('register') a new filter with the add_output_filter method on
          > the request object:
          >
          > $r->add_output_filter(\&callback);
          >
          > And, you can remove a downstream filter (from within an upstream filter) with:
          >
          > $next_f = $f->next;
          > $next_f->remove;

          And you can also do that from the FilterInitHandler phase
          http://perl.apache.org/docs/2.0/user/handlers/filters.html#Filter_Initialization_Phase

          > ...or even any subsequent invocations of the current filter (i.e., for
          > the current request) with:
          >
          > $f->remove;
          >
          > n.b. I'm not sure if it is possible to remove a downstream filter from
          > within a handler, since it appears you need the $f (filter) object to
          > do a remove... (can one reference the filter object from the request
          > object?)

          It's possible, since you can traverse the filter chain using the ->next
          http://perl.apache.org/docs/2.0/api/Apache/Filter.html#C_next_
          and you can access the filter stack with ->input_filters:
          http://perl.apache.org/docs/2.0/api/Apache/Connection.html#C_input_filters_
          http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_input_filters_
          and ->output_filters:
          http://perl.apache.org/docs/2.0/api/Apache/Connection.html#C_output_filters_
          http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_output_filters_

          > For more explanation that will probably put you on the right track, see:
          > http://perl.apache.org/docs/2.0/api/Apache/Filter.html

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

          --
          __________________________________________________________________
          Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
          http://stason.org/ mod_perl Guide ---> http://perl.apache.org
          mailto:stas@... http://use.perl.org http://apacheweek.com
          http://modperlbook.org http://apache.org http://ticketmaster.com
        Your message has been successfully submitted and would be delivered to recipients shortly.