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

[mp2] CONTENT_LENGTH & input filter

Expand Messages
  • Micah Johnson
    Hi, I m trying to use a pre-existing CGI script without modification. I d like to use an input filter to tack on something to the POST string. My filter adds
    Message 1 of 2 , May 3, 2004
      Hi,

      I'm trying to use a pre-existing CGI script without
      modification. I'd like to use an input filter to tack
      on something to the POST string. My filter adds the
      string, but the CGI sees a CONTENT_LENGTH
      environmental variable that corresponds to its
      original length. How do I update the CONTENT_LENGTH?

      Here's the filter code:

      package MyApache::AddConstraint;

      use strict;
      use warnings;

      use base qw(Apache::Filter);

      use Apache::Const -compile => 'OK';

      use constant BUFF_LEN => 1024;

      sub handler : FilterRequestHandler {
      my $f = shift;

      while ($f->read(my $buffer, BUFF_LEN)) {
      $f->print($buffer);
      }
      my $bparam = "&special=1";
      $f->print($bparam);

      Apache::OK;
      }
      1;

      The relevant conf is:

      <Location /cgi-perl>
      SetHandler perl-script
      PerlHandler ModPerl::PerlRun
      Options ExecCGI
      PerlSendHeader On
      </Location>

      PerlModule MyApache::AddConstraint
      <Location /cgi-perl/test>
      PerlInputFilterHandler MyApache::AddConstraint
      </Location>

      I've tried setting %ENV in my filter, setting
      CONTENT_LENGTH with $f->r->subprocess_env, and using
      headers_out->set('Content-Length'). In the first two
      cases, I see no effect, while the last applies to the
      length of the entire request, not just the POST
      string.
      Any help is appreciated.

      Thanks,
      Micah







      __________________________________
      Do you Yahoo!?
      Win a $20,000 Career Makeover at Yahoo! HotJobs
      http://hotjobs.sweepstakes.yahoo.com/careermakeover

      --
      Report problems: http://perl.apache.org/bugs/
      Mail list info: http://perl.apache.org/maillist/modperl.html
      List etiquette: http://perl.apache.org/maillist/email-etiquette.html
    • Stas Bekman
      ... You can do that only in the Connection level filter, Request level filter is too late. ... ^^^^ That s headers *out* (==response), you want headers_in. I
      Message 2 of 2 , May 3, 2004
        Micah Johnson wrote:
        > Hi,
        >
        > I'm trying to use a pre-existing CGI script without
        > modification. I'd like to use an input filter to tack
        > on something to the POST string. My filter adds the
        > string, but the CGI sees a CONTENT_LENGTH
        > environmental variable that corresponds to its
        > original length. How do I update the CONTENT_LENGTH?

        You can do that only in the Connection level filter, Request level filter is
        too late.

        > I've tried setting %ENV in my filter, setting
        > CONTENT_LENGTH with $f->r->subprocess_env, and using
        > headers_out->set('Content-Length'). In the first two
        ^^^^

        That's headers *out* (==response), you want headers_in. I haven't tried that,
        but it may work in any phase before the response handler (instead of
        connection filter).

        --
        __________________________________________________________________
        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

        --
        Report problems: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
        List etiquette: http://perl.apache.org/maillist/email-etiquette.html
      Your message has been successfully submitted and would be delivered to recipients shortly.