Torsten Foertsch wrote:
On Mon 22 Dec 2008, André Warnier wrote:I could do this the hard way by using LWP to just issue a new HTTP request to localhost and get the content, before I go on with my current request. But I figure there must be an easier and more efficient way, no ? Looking at the explanations for sub-requests, lookup_uri etc.., I get the impression however that calling these, pretty much terminates the current request, and replaces it by the one I'm calling. Which is not what I want. I want to continue processing the current request but using the response from my other request.Look at what mod_include does to get an impression about subrequests. You can use subrequests in 3 ways:1) lookup_uri or similar creates the subreq and runs it up to fixup. Then you can use any information the subreq has gathered so far, that means authentication, finfo etc.2) run it to include the output of the subreq into the current document more or less unmodified. To do that you create the subreq, install the necessary output filters and run() it.3) run it to process the output in some other way. That can be done for example this way:my $content=''; my $subr=$r->lookup_uri( $uri ); $subr->add_output_filter( sub { my ($f, $bb) = @_; while (my $e = $bb->first) { $e->read(my $buf); $content.=$buf; $e->delete; } return Apache2::Const::OK; }); $subr->run; my $rc=$subr->status; my $ct=$subr->content_type;Now, $content holds the response body, $rc the HTTP status code and $ct the subreq's content type.In all cases a subreq returns control to the calling request. An internal_redirect on the other hand almost completely takes over the request without return to the calling req.Torsten
Thanks much. That's exactly what I was looking for. --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx