Return-Path: X-Original-To: apmail-trafficserver-users-archive@www.apache.org Delivered-To: apmail-trafficserver-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 065699FA8 for ; Wed, 18 Apr 2012 08:21:24 +0000 (UTC) Received: (qmail 27053 invoked by uid 500); 18 Apr 2012 08:21:23 -0000 Delivered-To: apmail-trafficserver-users-archive@trafficserver.apache.org Received: (qmail 27010 invoked by uid 500); 18 Apr 2012 08:21:23 -0000 Mailing-List: contact users-help@trafficserver.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@trafficserver.apache.org Delivered-To: mailing list users@trafficserver.apache.org Received: (qmail 26992 invoked by uid 99); 18 Apr 2012 08:21:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 08:21:23 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of servalaneq@hotmail.com designates 65.55.90.205 as permitted sender) Received: from [65.55.90.205] (HELO snt0-omc4-s2.snt0.hotmail.com) (65.55.90.205) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 08:21:12 +0000 Received: from SNT133-W27 ([65.55.90.200]) by snt0-omc4-s2.snt0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 18 Apr 2012 01:20:51 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_8f604f9f-e6ea-4a6c-a6fc-d0f36511d5f3_" X-Originating-IP: [213.86.197.188] From: Servalan eq To: Subject: RE: Redirection (302 or 301) from a non remap plugin. Date: Wed, 18 Apr 2012 18:20:51 +1000 Importance: Normal In-Reply-To: <4F8C8849.7010806@apache.org> References: ,<4F8C8849.7010806@apache.org> MIME-Version: 1.0 X-OriginalArrivalTime: 18 Apr 2012 08:20:51.0381 (UTC) FILETIME=[2A9D5650:01CD1D3C] --_8f604f9f-e6ea-4a6c-a6fc-d0f36511d5f3_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > Date: Mon=2C 16 Apr 2012 14:59:53 -0600 > From: zwoop@apache.org > To: users@trafficserver.apache.org > CC: servalaneq@hotmail.com > Subject: Re: Redirection (302 or 301) from a non remap plugin. >=20 > On 4/16/12 8:59 AM=2C 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 =3D 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=2C=20 > > TSUrlPathSet > > and then > > > > TSSkipRemappingSet(txnp=2C 1)=3B > > but in some cases I need to issue a redirect request. > > >=20 > You can not use any o fthe "RRI" stuff in anything but a remap plugin (it= =20 > simply doesn't apply or map to anything in the core). You should however= =20 > just have to set the appopriate response headers=2C and response codes.=20 > There's for example a blacklist plugin example=2C which shows one way to = do this. >=20 > -- Leif >=20 >=20 Thanks Leif=2C that worked once I realised I needed to add the status with TSHttpHdrStatusSet(bufp=2C hdr_loc=2C TS_HTTP_STATUS_MOVED_TEMPORARILY= )=3BTSUrlHostGetand the location header using (say)TSMimeHdrFieldCreateNam= ed(reqp=2C hdr_loc=2C TS_MIME_FIELD_LOCATION=2C=20 TS_MIME_LEN_LOCATION =2C &new_field)=3BTSMimeHdrFieldValueStringInsert(reqp= =2C hdr_loc=2C new_field=2C -1=2C val=2C val_len)=3BTSMimeHdrFieldAppend(r= eqp=2C hdr_loc=2C new_field)=3B To the _response_ header buffer=2C 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_RE= AD_REQUEST_HDR handler is failing=2C even though getting it manually with TSMimeHdrFieldFind(.. is working=2C and returns the Host (and port). thanks very much for all your help Servalan = --_8f604f9f-e6ea-4a6c-a6fc-d0f36511d5f3_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

>=3B Date: Mon=2C 16 Apr 2012 14:59:53 -0600
>= =3B From: zwoop@apache.org
>=3B To: users@trafficserver.apache.org
= >=3B CC: servalaneq@hotmail.com
>=3B Subject: Re: Redirection (302 o= r 301) from a non remap plugin.
>=3B
>=3B On 4/16/12 8:59 AM=2C = Servalan eq wrote:
>=3B >=3B Is there a way to do a (302) redirectio= n from the non remap plugin?
>=3B >=3B
>=3B >=3B I have a rem= ap plugin where this works - by setting he elements of the URL
>=3B &g= t=3B and then setting redirect =3D 1 on the TSRemapRequestInfo object.
&= gt=3B >=3B
>=3B >=3B From a standard plugin hooked to the TS_EVENT= _HTTP_READ_REQUEST_HDR I
>=3B >=3B have my two servers being reverse= proxied by calling TSUrlHostSet=2C
>=3B >=3B TSUrlPathSet
>= =3B >=3B and then
>=3B >=3B
>=3B >=3B TSSkipRemappingSet(= txnp=2C 1)=3B
>=3B >=3B but in some cases I need to issue a redirect= request.
>=3B >=3B
>=3B
>=3B You can not use any o fthe = "RRI" stuff in anything but a remap plugin (it
>=3B simply doesn't ap= ply or map to anything in the core). You should however
>=3B just hav= e to set the appopriate response headers=2C and response codes.
>=3B = There's for example a blacklist plugin example=2C which shows one way to do= this.
>=3B
>=3B -- Leif
>=3B
>=3B
Tha= nks Leif=2C that worked once I realised I needed to add the  =3Bstatus = with

 =3B  =3B  =3BTSHttpHdrStatusSet(= bufp=2C hdr_loc=2C =3BTS_HTTP_STATUS_MOVED_TEMPORARILY)=3B
TS= UrlHostGet
and the location header using  =3B(say)
= TSMimeHdrFieldCreateNamed(reqp=2C hdr_loc=2C =3BTS_MIME_FIELD_LOCATION=2C =3B TS_MIME_LEN_LOCATION =3B=2C &=3B= new_field)=3B
TSMimeHdrFieldValueStringInsert(reqp=2C hdr_= loc=2C new_field=2C -1=2C  =3Bval=2C val_len)=3B
TSMimeHdrFie= ldAppend(reqp=2C hdr_loc=2C new_field)=3B

To the _= response_ header buffer=2C and so I had to hook my continuation to the = =3BTS_EVENT_HTTP_SEND_RESPONSE_HDR event and wait till then.

=
The only problem I now have is that my =3BTSUrlHostGet in th= e =3BTS_EVENT_HTTP_READ_REQUEST_HDR handler is failing=2C even though g= etting it manually with

TSMimeHdrFieldFind(..

is working=2C and returns the Host (and port).

thanks very much for all your help

Servalan
= --_8f604f9f-e6ea-4a6c-a6fc-d0f36511d5f3_--