> Date: Mon, 16 Apr 2012 14:59:53 -0600
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> Subject: Re: Redirection (302 or 301) from a non remap plugin.
> 
> On 4/16/12 8:59 AM, Servalan eq wrote:
> > Is there a way to do a (302) redirection from the non remap plugin?
> >
> > I have a remap plugin where this works - by setting he elements of the URL
> > and then setting redirect = 1 on the TSRemapRequestInfo object.
> >
> > From a standard plugin hooked to the TS_EVENT_HTTP_READ_REQUEST_HDR I
> > have my two servers being reverse proxied by calling TSUrlHostSet, 
> > TSUrlPathSet
> > and then
> >
> >   TSSkipRemappingSet(txnp, 1);
> > but in some cases I need to issue a redirect request.
> >
> 
> You can not use any o fthe "RRI" stuff in anything but a remap plugin (it 
> simply doesn't apply or map to anything in the core). You should however 
> just have to set the appopriate response headers, and response codes. 
> There's for example a blacklist plugin example, which shows one way to do 
> this.
> 
> -- Leif
> 
> 
Thanks Leif, that worked once I realised I needed to add the  status with
     TSHttpHdrStatusSet(bufp, hdr_loc, 
TS_HTTP_STATUS_MOVED_TEMPORARILY);TSUrlHostGetand the location header using  
(say)TSMimeHdrFieldCreateNamed(reqp, hdr_loc, TS_MIME_FIELD_LOCATION, 
TS_MIME_LEN_LOCATION , &new_field);TSMimeHdrFieldValueStringInsert(reqp, 
hdr_loc, new_field, -1,  val, val_len);TSMimeHdrFieldAppend(reqp, hdr_loc, 
new_field);
To the _response_ header buffer, and so I had to hook my continuation to the 
TS_EVENT_HTTP_SEND_RESPONSE_HDR event and wait till then.
The only problem I now have is that my TSUrlHostGet in the 
TS_EVENT_HTTP_READ_REQUEST_HDR handler is failing, even though getting it 
manually with
TSMimeHdrFieldFind(..
is working, and returns the Host (and port).
thanks very much for all your help
Servalan                                          

Reply via email to