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

Re: [MP2]how to catch the response body of a subrequest?

Expand Messages
  • Dorian Taylor
    ... this is true. i ll put something up on cpan tonight. .dorian
    Message 1 of 11 , May 27 4:06 PM
    • 0 Attachment
      > Or rewrite it to stash data from $bb->flatten, instead of stashing
      > brigades. In which case, no extra API is needed.

      this is true. i'll put something up on cpan tonight.

      .dorian
    • Dorian Taylor
      http://search.cpan.org/~dorian/ - now with working tests. 0.03 should show up soon (forgot to remove the bit about ap_save_brigade in 0.02)
      Message 2 of 11 , Jun 8, 2005
      • 0 Attachment
        http://search.cpan.org/~dorian/ - now with working tests.

        0.03 should show up soon (forgot to remove the bit about ap_save_brigade
        in 0.02)
      • Joe Schaefer
        ... Hmm, have you considered removing the _filter sub and writing it as a closure instead? Here s some code that I ve been using for that: use base
        Message 3 of 11 , Jun 8, 2005
        • 0 Attachment
          Dorian Taylor <dorian@...> writes:

          > http://search.cpan.org/~dorian/ - now with working tests.
          >
          > 0.03 should show up soon (forgot to remove the bit about
          > ap_save_brigade in 0.02)

          Hmm, have you considered removing the _filter sub and writing
          it as a closure instead? Here's some code that I've been using
          for that:

          use base "Apache2::Filter";
          ...
          my $content = "";
          $subr->add_output_filter(bless sub : FilterRequestHandler {
          my ($f, $bb) = @_;
          while (my $e = $bb->first) {
          $e->read(my $buf);
          $content .= $buf;
          $e->delete;
          }
          return Apache2::Const::OK;
          });

          $subr->run; # reads entire subrequest into $content

          This way your subrequest buckets are all consumed by the filter,
          and you don't need a pnote to store the captured subrequest
          (I really don't know why you want to use ap_save_brigade). IMO
          dynamically creating filters using closures is a really nifty
          feature of mod_perl2; I use it to postprocess stuff stored
          inside a mod_authz_svn-protected subversion repository. Just *try*
          getting the authz info correct with a plain-old CGI script :-).

          --
          Joe Schaefer
        • Dorian Taylor
          ... i suppose i could do that. today is clean-my-modules-and-get-them-on-cpan day so perhaps later. ;) .d
          Message 4 of 11 , Jun 8, 2005
          • 0 Attachment
            > Hmm, have you considered removing the _filter sub and writing
            > it as a closure instead? Here's some code that I've been using
            > for that:

            i suppose i could do that. today is clean-my-modules-and-get-them-on-cpan
            day so perhaps later. ;)

            .d
          • Tom Schindl
            ... Hash: SHA1 [...] ... just for curiosity why do you bless the sub? [...] ... Version: GnuPG v1.4.0 (GNU/Linux) Comment: Using GnuPG with Thunderbird -
            Message 5 of 11 , Jun 10, 2005
            • 0 Attachment
              -----BEGIN PGP SIGNED MESSAGE-----
              Hash: SHA1

              [...]
              Joe Schaefer schrieb:

              | my $content = "";
              | $subr->add_output_filter(bless sub : FilterRequestHandler {
              | my ($f, $bb) = @_;
              | while (my $e = $bb->first) {
              | $e->read(my $buf);
              | $content .= $buf;
              | $e->delete;
              | }
              | return Apache2::Const::OK;
              | });
              |
              | $subr->run; # reads entire subrequest into $content

              just for curiosity why do you bless the sub?

              [...]
              -----BEGIN PGP SIGNATURE-----
              Version: GnuPG v1.4.0 (GNU/Linux)
              Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

              iD8DBQFCqUVXkVPeOFLgZFIRAoSFAJ47LkKdz0jjbumPJc2rKqJrekpKoACdGPEX
              YWyNGh7JpP/Huu5iRQ88Ojk=
              =QREe
              -----END PGP SIGNATURE-----
            • Joe Schaefer
              ... Cargo cult, I suppose; AFAICT it s not necessary. Thanks for the spot. -- Joe Schaefer
              Message 6 of 11 , Jun 10, 2005
              • 0 Attachment
                Tom Schindl <tomAtLinux@...> writes:

                > -----BEGIN PGP SIGNED MESSAGE-----
                > Hash: SHA1
                >
                > [...]
                > Joe Schaefer schrieb:
                >
                > | my $content = "";
                > | $subr->add_output_filter(bless sub : FilterRequestHandler {
                > | my ($f, $bb) = @_;
                > | while (my $e = $bb->first) {
                > | $e->read(my $buf);
                > | $content .= $buf;
                > | $e->delete;
                > | }
                > | return Apache2::Const::OK;
                > | });
                > |
                > | $subr->run; # reads entire subrequest into $content
                >
                > just for curiosity why do you bless the sub?

                Cargo cult, I suppose; AFAICT it's not necessary.
                Thanks for the spot.

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