httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Lewis <...@joe-lewis.com>
Subject Re: [Apache Module] Request External Redirection
Date Mon, 14 Jan 2008 15:31:18 GMT
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 <joe@joe-lewis.com> 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 <http://sharktooth.org/>
"Divide the fire, and you will sooner put it out." - Publius Syrus

Mime
View raw message