Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 92746 invoked from network); 14 Jan 2008 15:31:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Jan 2008 15:31:52 -0000 Received: (qmail 52821 invoked by uid 500); 14 Jan 2008 15:31:41 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 52801 invoked by uid 500); 14 Jan 2008 15:31:41 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 52792 invoked by uid 99); 14 Jan 2008 15:31:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jan 2008 07:31:41 -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 [166.70.186.42] (HELO onyx.sharktooth.org) (166.70.186.42) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jan 2008 15:31:15 +0000 Received: from [137.65.53.197] by onyx.sharktooth.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1JER9L-000Gzl-Lt for modules-dev@httpd.apache.org; Mon, 14 Jan 2008 08:22:57 -0700 Message-ID: <478B8046.4040206@joe-lewis.com> Date: Mon, 14 Jan 2008 08:31:18 -0700 From: Joe Lewis User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: modules-dev@httpd.apache.org References: <9dc7421e0801131158g361df65dpf026b5b05ff915bb@mail.gmail.com> <478B7277.4040909@joe-lewis.com> <9dc7421e0801140650q25f20749p450feaafe529e433@mail.gmail.com> <20080114150037.GE23798@suse.de> In-Reply-To: <20080114150037.GE23798@suse.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 137.65.53.197 X-SA-Exim-Mail-From: joe@joe-lewis.com X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on onyx.sharktooth.org X-Spam-Level: Subject: Re: [Apache Module] Request External Redirection X-SA-Exim-Version: 4.2 X-SA-Exim-Scanned: Yes (on onyx.sharktooth.org) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.1.7 Dr. Peter Poeml wrote: > On Mon, Jan 14, 2008 at 03:50:25PM +0100, karim Bendadda wrote: > >> Thanks for your answer! But I don't understand the second way to implement >> it?? "it can respond with a Location: header and a status of 302."?? >> >> On 1/14/08, Joe Lewis wrote: >> >>> karim Bendadda wrote: >>> >>>> I'm writing a module (MyModule_mod.c) wich has an *HTTP >>>> >>> request* as >>> >>>> input . I want to add an information to the request (an integer) and >>>> redirect it to an *external *server ...Did you know any method for doing >>>> this? >>>> >>>> >>>> >>> There are two paths. The server can PROXY to the external server (e.g. >>> grab the result from the external server and then relay that to the >>> client) or it can respond with a Location: header and a status of 302. >>> Figure out which you wanted to do, and if you struggle to implement it, >>> let us know. >>> > > In your handler, you would do something like this to implement the latter: > > /* set a "Location:" header and 302 redirect. */ > > /* assemble the url by appending the filename to a baseurl */ > uri = apr_pstrcat(r->pool, baseurl, filename, NULL); > > apr_table_setn(r->headers_out, "Location", uri); > > return HTTP_MOVED_TEMPORARILY; > > Peter > Exactly! What it does is forces the web client to go to the external server and request the resource/URI rather than the web server getting it for the web client. It's a standard in the HTTP protocols that 302 response codes work in a specific fashion. Joe -- Joseph Lewis "Divide the fire, and you will sooner put it out." - Publius Syrus