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 67E87933E for ; Fri, 13 Apr 2012 16:18:12 +0000 (UTC) Received: (qmail 61559 invoked by uid 500); 13 Apr 2012 16:18:12 -0000 Delivered-To: apmail-trafficserver-users-archive@trafficserver.apache.org Received: (qmail 61527 invoked by uid 500); 13 Apr 2012 16:18:12 -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 61518 invoked by uid 99); 13 Apr 2012 16:18:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Apr 2012 16:18:12 +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.226 as permitted sender) Received: from [65.55.90.226] (HELO snt0-omc4-s23.snt0.hotmail.com) (65.55.90.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Apr 2012 16:18:03 +0000 Received: from SNT133-W57 ([65.55.90.199]) by snt0-omc4-s23.snt0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 13 Apr 2012 09:17:41 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_18733833-8f19-410c-855c-f9b61bc563d8_" X-Originating-IP: [213.86.197.188] From: Servalan eq To: Subject: RE: using curl during an http transaction Date: Sat, 14 Apr 2012 02:17:41 +1000 Importance: Normal In-Reply-To: References: , MIME-Version: 1.0 X-OriginalArrivalTime: 13 Apr 2012 16:17:41.0503 (UTC) FILETIME=[F382C0F0:01CD1990] --_18733833-8f19-410c-855c-f9b61bc563d8_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Ah thanks. I have seen this with the multiple chunks - at this stage I am o= nly expecting tens of bytes=2C but it's a good idea to be careful. thanks From: Peter.Walsh@disney.com To: users@trafficserver.apache.org Date: Fri=2C 13 Apr 2012 08:48:00 -0700 Subject: Re: using curl during an http transaction I'm not sure for the redirect question because we don't use that feature. = =20 However=2C one last thing I want to mention with regard to HttpConnect. Mak= e sure to test this with large responses because its possible to get multip= le READ_READY/COMPLETE callbacks when the response size is large. Many exam= ples we've seen don't handle this correctly and we stumbled on it at first. From: Servalan eq Reply-To: "users@trafficserver.apache.org" Date: Fri=2C 13 Apr 2012 08:31:33 -0700 To: "users@trafficserver.apache.org" Subject: RE: using curl during an http transaction Thanks very much Peter.I have got this working pretty much as you describe = - I just need to go back to doing the remap type operations from a remap pl= ugin now. I presume I can do forwarding or redirection pretty much as normal using TS= UrlHostSet=2C TSUrlPathSet etc.The one thing I can't see how do to is the e= quivalent of=20 rri->redirect =3D 1 on the TSRemapRequestInfo=2C as I can't see h= ow to get access to this from a standard plugin event. thanks very much for your help. Servalan > From: Peter.Walsh@disney.com > To: users@trafficserver.apache.org > Date: Thu=2C 12 Apr 2012 11:04:46 -0700 > Subject: Re: using curl during an http transaction >=20 > Hello=2C > You may have already gotten this working=2C but here's some basic steps..= . >=20 > 1.) Call TSHttpConnect with a sockaddr object=2C which returns a TSVConn > 2.) Call TSVConnWrite using the returned TSVConn=2C a continuation=2C a b= uffer > reader containing your request=2C and the content length. This returns a > TSVIO >=20 > example:=20 >=20 > RequestVio =3D TSVConnWrite(vconn=2C contp=2C > mServerRequestBufferReader=2C > TSIOBufferReaderAvail(mServerRequestBufferReader))=3B >=20 > NOTE: There are different ways to get the URI into > mServerRequestBufferReader=2C we used the ATS API's to create a new HTTP > header=2C set all the fields (ie scheme=2C host=2C path=2C etc) and used = the > TSHttpHdrPrint to get the buffer into mServerRequestBufferReader. >=20 > 3.) Your handler will get called back with > TS_EVENT_VCONN_WRITE_READY/COMPLETE. Once its complete=2C you can initiat= e a > read using TSVConnRead on the TSVConn returned in step 1=2C and a respons= e > buffer=2C and the size of data you want. >=20 > Example: TSVConnRead(vconn=2C contp=2C >mServerResponseBuffer=2C INT_MAX)= =3B >=20 > This returns a new Response TSVIO >=20 > 4.) Once you've initiated the read=2C your handler will get called back w= ith > TS_EVENT_VCONN_READ_READY/COMPLETE events=2C at which point you can read > data from the response buffer. This is just like the reading done in the > transform plugins=2C so if you look at those you'll find tons of examples >=20 > Hope that helps >=20 > -Pete >=20 >=20 > On 4/5/12 9:57 AM=2C "Walsh=2C Peter" wrote: >=20 > >Hello=2C > >I worked with Erik on this=2C and we did get it working eventually. It = was > >quite difficult to get this working as there aren't any good examples=2C > >but we pieced together what we could based on the InkAPITest class and > >the example protocol plugin that uses TSNetConnect=2C which is somewhat > >similar. =20 > > > >I'm a bit swamped right now=2C but when I have a minute I'll post a > >response to this with some helpful tips=2C gotchas=2C etc. > > > >-Pete=20 > > > >-----Original Message----- > >From: Servalan eq [mailto:servalaneq@hotmail.com] > >Sent: Thursday=2C April 05=2C 2012 7:27 AM > >To: users@trafficserver.apache.org > >Subject: RE: using curl during an http transaction > > > > > > > > > >Hi Erik=2C did you ever get this TSHttpConnect call working? > >I too am looking for some good examples to call a seperate HTTP service > >while processing a request to determine how to handle it. > >thanks very much=2C > >Servalan > > > >> On 04/20/2011 02:16 PM=2C Earle=2C Erik wrote: > > > >> Is there an example usage of TSHttpConnect somewhere? I did not > >see any in the examples. > > > >=20 > > > >=20 > > > >--=20 > > > >Erik > >Earle 206.664.4016 tie line: > >8.664.4016 erik.earle@disney.com > > > >Walt > >Disney Connected and Advanced Technologies > > > >925 4th Ave - Suite 1600 - Seattle - 98104 > > > >=20 > > > >From: Leif Hedstrom > >[mailto:zwoop@apache.org] > > > >Sent: Wednesday=2C April 20=2C 2011 2:33 PM > > > >To: users@trafficserver.apache.org > > > >Cc: Earle=2C Erik > > > >Subject: Re: using curl during an http transaction > > > >=20 > > > >On > >04/20/2011 02:16 PM=2C Earle=2C Erik wrote: > > > >Hi > >all. I'm new to the list and trafficserver. > > > >=20 > > > >I'm > >building a plugin to do OAuth 2. I'm looking to make a call to a separa= te > >(REST) service to do the OAuth token validation. > > > >=20 > > > >Does anyone > >have experience with using something like curl or vconnections=2C etc. t= o > >make a > >separate http request during an http transaction? > > > >=20 > > > > > > > >You want to use the appropriate APIs that we provide to perform HTTP > >requests=2C > >e.g. TSNetConnect() or TSHttpConnect(). > > > > > > > >-- leif =20 >=20 = --_18733833-8f19-410c-855c-f9b61bc563d8_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Ah thanks. I have seen this with the multiple chunks - at this stage I am o= nly expecting tens of bytes=2C but it's a good idea to be careful.

=
thanks


From: Peter.Walsh@disney.com
To: users@trafficserver.a= pache.org
Date: Fri=2C 13 Apr 2012 08:48:00 -0700
Subject: Re: using = curl during an http transaction

I'm not sure f= or the redirect question because we don't use that feature.  =3B
<= div>
However=2C one last thing I want to mention with regard = to HttpConnect. Make sure to test this with large responses because its pos= sible to get multiple READ_READY/COMPLETE callbacks when the response size = is large. Many examples we've seen don't handle this correctly and we stumb= led on it at first.

From: Servalan eq <=3Bservalaneq@hotmail.com>=3B
Reply-To: "user= s@trafficserver.apache.org" <=3Busers@trafficserver.apache.org>=3B
Date: Fri=2C 13 Apr 2012 08:31:33 -0700
To: "users@trafficserver.apache.org" <=3Busers@trafficserver.apache.org>=3B
Subject: RE: using curl during an ht= tp transaction


Thanks = very much Peter.
I have got this working pretty much as you describe - = I just need to go back to doing the remap type operations from a remap plug= in now.

I presume I can do forwarding or redirecti= on pretty much as normal using =3BTSUrlHostSet=2C = TSUrlPathSet etc.
The one thing I can't see how do to is the equivalent of =3B<= /span>

rri->=3Bredirect =3D 1
on the TSRemapRequestInfo=2C as I can't see how to get acc= ess to this from a standard plugin event.

thanks very much for your help.

= Servalan

>=3B From: Peter.Walsh@disney.= com
>=3B To: use= rs@trafficserver.apache.org
>=3B Date: Thu=2C 12 Apr 2012 11:04:46= -0700
>=3B Subject: Re: using curl during an http transaction
>= =3B
>=3B Hello=2C
>=3B You may have already gotten this working= =2C but here's some basic steps...
>=3B
>=3B 1.) Call TSHttpConn= ect with a sockaddr object=2C which returns a TSVConn
>=3B 2.) Call TS= VConnWrite using the returned TSVConn=2C a continuation=2C a buffer
>= =3B reader containing your request=2C and the content length. This returns = a
>=3B TSVIO
>=3B
>=3B example:
>=3B
>=3B Reque= stVio =3D TSVConnWrite(vconn=2C contp=2C
>=3B mSer= verRequestBufferReader=2C
>=3B TSIOBufferReaderAvail(mServerRequestBuf= ferReader))=3B
>=3B
>=3B NOTE: There are different ways to get t= he URI into
>=3B mServerRequestBufferReader=2C we used the ATS API's t= o create a new HTTP
>=3B header=2C set all the fields (ie scheme=2C ho= st=2C path=2C etc) and used the
>=3B TSHttpHdrPrint to get the buffer = into mServerRequestBufferReader.
>=3B
>=3B 3.) Your handler will= get called back with
>=3B TS_EVENT_VCONN_WRITE_READY/COMPLETE. Once i= ts complete=2C you can initiate a
>=3B read using TSVConnRead on the T= SVConn returned in step 1=2C and a response
>=3B buffer=2C and the siz= e of data you want.
>=3B
>=3B Example: TSVConnRead(vconn=2C cont= p=2C >=3BmServerResponseBuffer=2C INT_MAX)=3B
>=3B
>=3B This r= eturns a new Response TSVIO
>=3B
>=3B 4.) Once you've initiated = the read=2C your handler will get called back with
>=3B TS_EVENT_VCONN= _READ_READY/COMPLETE events=2C at which point you can read
>=3B data f= rom the response buffer. This is just like the reading done in the
>= =3B transform plugins=2C so if you look at those you'll find tons of exampl= es
>=3B
>=3B Hope that helps
>=3B
>=3B -Pete
>= =3B
>=3B
>=3B On 4/5/12 9:57 AM=2C "Walsh=2C Peter" <=3BPeter.Walsh@disney.com>=3B wrote= :
>=3B
>=3B >=3BHello=2C
>=3B >=3BI worked with Erik on= this=2C and we did get it working eventually. It was
>=3B >=3Bquit= e difficult to get this working as there aren't any good examples=2C
>= =3B >=3Bbut we pieced together what we could based on the InkAPITest clas= s and
>=3B >=3Bthe example protocol plugin that uses TSNetConnect=2C= which is somewhat
>=3B >=3Bsimilar.
>=3B >=3B
>=3B &g= t=3BI'm a bit swamped right now=2C but when I have a minute I'll post a
= >=3B >=3Bresponse to this with some helpful tips=2C gotchas=2C etc.
= >=3B >=3B
>=3B >=3B-Pete
>=3B >=3B
>=3B >=3B-----= Original Message-----
>=3B >=3BFrom: Servalan eq [mailto:servalaneq@hotmail.com]
>=3B >=3B= Sent: Thursday=2C April 05=2C 2012 7:27 AM
>=3B >=3BTo: users@trafficserver.apache.org>=3B >=3BSubject: RE: using curl during an http transaction
>=3B = >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3BH= i Erik=2C did you ever get this TSHttpConnect call working?
>=3B >= =3BI too am looking for some good examples to call a seperate HTTP service<= br>>=3B >=3Bwhile processing a request to determine how to handle it.>=3B >=3Bthanks very much=2C
>=3B >=3BServalan
>=3B >= =3B
>=3B >=3B>=3B On 04/20/2011 02:16 PM=2C Earle=2C Erik wrote:>=3B >=3B
>=3B >=3B>=3B Is there an example usage of TSHttpC= onnect somewhere? I did not
>=3B >=3Bsee any in the examples.
&g= t=3B >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3B
>=3B = >=3B
>=3B >=3B--
>=3B >=3B
>=3B >=3BErik
>=3B = >=3BEarle 206.664.4016 tie line:
>=3B >=3B8.664.4016 <= a href=3D"mailto:erik.earle@disney.com">erik.earle@disney.com
>=3B= >=3B
>=3B >=3BWalt
>=3B >=3BDisney Connected and Advanced = Technologies
>=3B >=3B
>=3B >=3B925 4th Ave - Suite 1600 - Se= attle - 98104
>=3B >=3B
>=3B >=3B
>=3B >=3B
>=3B= >=3BFrom: Leif Hedstrom
>=3B >=3B[mailto:zwoop@apache.org]
>=3B >=3B
>=3B >=3BSent: We= dnesday=2C April 20=2C 2011 2:33 PM
>=3B >=3B
>=3B >=3BTo: users@trafficserver.apache.= org
>=3B >=3B
>=3B >=3BCc: Earle=2C Erik
>=3B >=3B=
>=3B >=3BSubject: Re: using curl during an http transaction
>= =3B >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3BOn
>=3B = >=3B04/20/2011 02:16 PM=2C Earle=2C Erik wrote:
>=3B >=3B
>= =3B >=3BHi
>=3B >=3Ball. I'm new to the list and trafficserver.<= br>>=3B >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3BI'm
= >=3B >=3Bbuilding a plugin to do OAuth 2. I'm looking to make a call t= o a separate
>=3B >=3B(REST) service to do the OAuth token validatio= n.
>=3B >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3BDoes= anyone
>=3B >=3Bhave experience with using something like curl or v= connections=2C etc. to
>=3B >=3Bmake a
>=3B >=3Bseparate http= request during an http transaction?
>=3B >=3B
>=3B >=3B
= >=3B >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3BYou want to= use the appropriate APIs that we provide to perform HTTP
>=3B >=3Br= equests=2C
>=3B >=3Be.g. TSNetConnect() or TSHttpConnect().
>= =3B >=3B
>=3B >=3B
>=3B >=3B
>=3B >=3B-- leif =
>=3B
=
= --_18733833-8f19-410c-855c-f9b61bc563d8_--