Re: write results of subrequest to file
Geoffrey Young wrote: Perrin Harkins wrote: On Fri, 2004-08-13 at 11:06, Geoffrey Young wrote: you can't do that with mod_perl 1.0 - you can $sub-run() but that result goes right to the client. For comparison, how would you do this in mp2? With a filter? pretty much. I believe that subrequests in apache2 have the same limitations as before wrt calling run(). but if the main reason you want to capture a subrequest is to post-process dynamic content then you can simply insert an output filter to do that for you, as that is what they were designed for. Nah, you can do it in a much cleaner way in mp2. See http://perl.apache.org/docs/2.0/api/Apache/SubRequest.html#C_lookup_uri_, but basically you can my $data; my $subr = $r-lookup_uri($uri, $filter); $subr-run; And $filter can be a very simple output filter that just stashes data as it comes out or anything else you feel like doing. --Geoff -- Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5 http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5 signature.asc Description: OpenPGP digital signature
Re: write results of subrequest to file
Philippe M. Chiasson wrote: Geoffrey Young wrote: Perrin Harkins wrote: On Fri, 2004-08-13 at 11:06, Geoffrey Young wrote: you can't do that with mod_perl 1.0 - you can $sub-run() but that result goes right to the client. For comparison, how would you do this in mp2? With a filter? pretty much. I believe that subrequests in apache2 have the same limitations as before wrt calling run(). but if the main reason you want to capture a subrequest is to post-process dynamic content then you can simply insert an output filter to do that for you, as that is what they were designed for. Nah, you can do it in a much cleaner way in mp2. See http://perl.apache.org/docs/2.0/api/Apache/SubRequest.html#C_lookup_uri_, but basically you can my $data; my $subr = $r-lookup_uri($uri, $filter); $subr-run; And $filter can be a very simple output filter that just stashes data as it comes out or anything else you feel like doing. Hmm, and where do you get this $filter object from? Do you have a working example? -- __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] 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
Re: write results of subrequest to file
Philippe M. Chiasson wrote: Stas Bekman wrote: Philippe M. Chiasson wrote: Geoffrey Young wrote: Perrin Harkins wrote: On Fri, 2004-08-13 at 11:06, Geoffrey Young wrote: you can't do that with mod_perl 1.0 - you can $sub-run() but that result goes right to the client. For comparison, how would you do this in mp2? With a filter? pretty much. I believe that subrequests in apache2 have the same limitations as before wrt calling run(). but if the main reason you want to capture a subrequest is to post-process dynamic content then you can simply insert an output filter to do that for you, as that is what they were designed for. Nah, you can do it in a much cleaner way in mp2. See http://perl.apache.org/docs/2.0/api/Apache/SubRequest.html#C_lookup_uri_, but basically you can my $data; my $subr = $r-lookup_uri($uri, $filter); $subr-run; And $filter can be a very simple output filter that just stashes data as it comes out or anything else you feel like doing. Hmm, and where do you get this $filter object from? Do you have a working example? Hmm, I think you just got me there. I didn't think long enough before answering that one ;-) I can see why one can't do that now that I've looked at code for a few minutes, and sorry for misleading anybody on this one. Ah, no, I think it's quite do-able, I just thought that you had an example at hand. The $filter argument is just a pointer to somewhere in the filter chain. So I suppose on could add a filter for the subrequest and pass $filter: $subr-output_filters. But as I don't have a test, I can't vouch for it to work. If you want I can write a test for it later, but now I need to resolve if a few other issues first. So let me know if you want me to work on this. -- __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] 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
write results of subrequest to file
I want to publish the result of a dynamic request to a file. So within a handler I create a subrequest that gives me the result of the dynamic request. Something like: $sub = $r-lookup_uri($page?id=$id); Now I want to get the results of this request and stream it into a file. Would using Apache::File be a possibillity? The main handler will continue and print if the write has been successfull. Cheers, Marc -- 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
Re: write results of subrequest to file
MJW Lambrichs wrote: I want to publish the result of a dynamic request to a file. So within a handler I create a subrequest that gives me the result of the dynamic request. Something like: $sub = $r-lookup_uri($page?id=$id); Now I want to get the results of this request and stream it into a file. you can't do that with mod_perl 1.0 - you can $sub-run() but that result goes right to the client. basically, you need to issue a full request to the server using lwp or some similar tool. see the discussion in recipe 5.7 in the mod_perl developer's cookbook, including this code http://www.modperlcookbook.org/code/ch05/Cookbook/SubRequestContent.pm which is probably overly complex for simple needs but includes the LWP and uri-manipulating code you would want. HTH --Geoff -- 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
Re: write results of subrequest to file
On Fri, 2004-08-13 at 11:06, Geoffrey Young wrote: you can't do that with mod_perl 1.0 - you can $sub-run() but that result goes right to the client. For comparison, how would you do this in mp2? With a filter? - Perrin -- 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
Re: write results of subrequest to file
Perrin Harkins wrote: On Fri, 2004-08-13 at 11:06, Geoffrey Young wrote: you can't do that with mod_perl 1.0 - you can $sub-run() but that result goes right to the client. For comparison, how would you do this in mp2? With a filter? pretty much. I believe that subrequests in apache2 have the same limitations as before wrt calling run(). but if the main reason you want to capture a subrequest is to post-process dynamic content then you can simply insert an output filter to do that for you, as that is what they were designed for. --Geoff -- 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