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

poking into request content?

Expand Messages
  • Jan Algermissen
    Hi, I want to write a Perl handler that pokes into the content of a request in order to see if a certain parameter is present and if so to change the request
    Message 1 of 4 , Jan 2, 2004
      Hi,

      I want to write a Perl handler that pokes into the content
      of a request in order to see if a certain parameter is present and
      if so to change the request method.

      Ok, I am finally aware that content() may onle be called once on
      a request object so any further handlers won't be able to see the
      original content.

      Is there a way to restore that data after calling content() or read()?

      (I had the idea that calling read might silently make the data available
      via content() too, but unfortunately this is not true.

      The practical reason for my question can be found here:

      http://search.cpan.org/~alger/Apache-MagicPOST/

      Thanks for any help or ideas.


      Jan


      --
      Jan Algermissen http://www.topicmapping.com
      Consultant & Programmer http://www.gooseworks.org

      --
      Reporting bugs: http://perl.apache.org/bugs/
      Mail list info: http://perl.apache.org/maillist/modperl.html
    • Geoffrey Young
      ... see Apache::Request- instance() HTH --Geoff -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
      Message 2 of 4 , Jan 2, 2004
        Jan Algermissen wrote:
        > Hi,
        >
        > I want to write a Perl handler that pokes into the content
        > of a request in order to see if a certain parameter is present and
        > if so to change the request method.
        >
        > Ok, I am finally aware that content() may onle be called once on
        > a request object so any further handlers won't be able to see the
        > original content.
        >
        > Is there a way to restore that data after calling content() or read()?

        see Apache::Request->instance()

        HTH

        --Geoff


        --
        Reporting bugs: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
      • Jan Algermissen
        ... Geoffrey-- thanks. I tried that but am I right in suspecting that subsequent handlers also need to work with Apache::Request? IOW: is there a way to use
        Message 3 of 4 , Jan 2, 2004
          Geoffrey Young wrote:
          >
          > Jan Algermissen wrote:
          > > Hi,
          > >
          > > I want to write a Perl handler that pokes into the content
          > > of a request in order to see if a certain parameter is present and
          > > if so to change the request method.
          > >
          > > Ok, I am finally aware that content() may onle be called once on
          > > a request object so any further handlers won't be able to see the
          > > original content.
          > >
          > > Is there a way to restore that data after calling content() or read()?
          >
          > see Apache::Request->instance()

          Geoffrey--

          thanks. I tried that but am I right in suspecting that subsequent handlers
          also need to work with Apache::Request? IOW: is there a way to use Apache::Request
          and later use the notrmal $r->content() call?

          I want to impose abslolutely no constraint on subsequent handlers (as they
          might not even be related to my application).

          Jan


          >
          > HTH
          >
          > --Geoff

          --
          Jan Algermissen http://www.topicmapping.com
          Consultant & Programmer http://www.gooseworks.org

          --
          Reporting bugs: http://perl.apache.org/bugs/
          Mail list info: http://perl.apache.org/maillist/modperl.html
        • Stas Bekman
          ... Not really. You could subclass $r, but your other handlers need to be aware of this. So it s not transparent. ... In which case you probably need to look
          Message 4 of 4 , Jan 2, 2004
            Jan Algermissen wrote:
            > Geoffrey Young wrote:
            >
            >>Jan Algermissen wrote:
            >>
            >>>Hi,
            >>>
            >>>I want to write a Perl handler that pokes into the content
            >>>of a request in order to see if a certain parameter is present and
            >>>if so to change the request method.
            >>>
            >>>Ok, I am finally aware that content() may onle be called once on
            >>>a request object so any further handlers won't be able to see the
            >>>original content.
            >>>
            >>>Is there a way to restore that data after calling content() or read()?
            >>
            >>see Apache::Request->instance()
            >
            >
            > Geoffrey--
            >
            > thanks. I tried that but am I right in suspecting that subsequent handlers
            > also need to work with Apache::Request? IOW: is there a way to use Apache::Request
            > and later use the notrmal $r->content() call?

            Not really. You could subclass $r, but your other handlers need to be aware of
            this. So it's not transparent.

            > I want to impose abslolutely no constraint on subsequent handlers (as they
            > might not even be related to my application).

            In which case you probably need to look at input filters available only with
            mod_perl 2. Though remember that the body filter will be invoked only if some
            handler is trying to consume the body.

            In fact Apache::Request 2, does exactly that - it injects itself as a filter,
            making the POSTed body available to any consumer that calls into libapreq's
            instance method (perl, c, php, whatever)

            __________________________________________________________________
            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


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