Return-Path: Delivered-To: apmail-httpd-users-archive@www.apache.org Received: (qmail 38759 invoked from network); 22 Dec 2008 09:07:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Dec 2008 09:07:07 -0000 Received: (qmail 30936 invoked by uid 500); 22 Dec 2008 09:06:57 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 30917 invoked by uid 500); 22 Dec 2008 09:06:57 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 30908 invoked by uid 99); 22 Dec 2008 09:06:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2008 01:06:57 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [212.85.38.174] (HELO popeye.combios.es) (212.85.38.174) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2008 09:06:49 +0000 Received: from [192.168.250.50] (p549EA650.dip0.t-ipconnect.de [84.158.166.80]) (authenticated bits=0) by popeye.combios.es (8.13.8/8.13.8/Debian-3) with ESMTP id mBM96Lew005410; Mon, 22 Dec 2008 10:06:25 +0100 Message-ID: <494F57B5.90604@ice-sa.com> Date: Mon, 22 Dec 2008 10:02:45 +0100 From: =?UTF-8?B?QW5kcsOpIFdhcm5pZXI=?= Reply-To: users@httpd.apache.org User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: users@httpd.apache.org CC: Torsten Foertsch References: <494ECB7E.5030204@ice-sa.com> <200812220055.43196.torsten.foertsch@gmx.net> In-Reply-To: <200812220055.43196.torsten.foertsch@gmx.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV 0.92.1/8790/Mon Dec 22 05:26:20 2008 on popeye.combios.es X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org Subject: [users@httpd] Re: sub-requests, lookup_uri and that kind of stuff 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 for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org " from the digest: users-digest-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org