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 5EF7D9DB6 for ; Thu, 5 Apr 2012 10:13:19 +0000 (UTC) Received: (qmail 76380 invoked by uid 500); 5 Apr 2012 10:13:19 -0000 Delivered-To: apmail-trafficserver-users-archive@trafficserver.apache.org Received: (qmail 76256 invoked by uid 500); 5 Apr 2012 10:13:18 -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 76242 invoked by uid 99); 5 Apr 2012 10:13:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2012 10:13:17 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of servalaneq@hotmail.com designates 65.55.90.231 as permitted sender) Received: from [65.55.90.231] (HELO snt0-omc4-s28.snt0.hotmail.com) (65.55.90.231) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2012 10:13:10 +0000 Received: from SNT133-W47 ([65.55.90.199]) by snt0-omc4-s28.snt0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 5 Apr 2012 03:12:49 -0700 Message-ID: X-Originating-IP: [213.86.197.188] From: Servalan eq To: Subject: RE: Calling an arbitrary http entpoint for advice in a remap plugin Date: Thu, 5 Apr 2012 20:12:49 +1000 Importance: Normal In-Reply-To: <4F7C64B5.9080105@apache.org> References: ,<4F7C64B5.9080105@apache.org> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 05 Apr 2012 10:12:49.0586 (UTC) FILETIME=[A79B5120:01CD1314] X-Virus-Checked: Checked by ClamAV on apache.org > On 4/4/12 6:36 AM=2C Servalan eq wrote:> > I am writing a remap plugin to= do a hybrid reverse proxy / redirection task.In some circumstances I want = to call out to a seperate http server (not related to the requests) do deci= de how to handle the requests.> > I've coded this up using libcurl=2C which= works but seems very slow - creating and destroying a curl_easy_init objec= t per call. Is there a way to call an HTTP GET during a plugin's process=2C= just passing some request parameters and headers using the internal ATSfun= ctionality?=A0> > It seems TSFetchRespGet or TSFetchURL might work=2C but I= can't see any way to make a new tsapi_httptxn with my call in it.> > thank= s very much=2C> >=A0>=A0> Yeah=2C none of this will work (well) in a remap = plugin. You need to=A0> rewrite this as e.g. a read-request-header hook=2C = and then use=A0> TSHttpConnect() (most likely) to fetch the content. This a= lso implies=A0> you have to yield and reschedule your continuation while wa= iting and=A0> processing the response. If not (and as you probably have not= iced with=A0> your remap plugin)=2C you will block the net-thread for the d= uration of=A0> the request. This is very bad=2C because all clients on that= thread are=A0> now stalled until your (curl) request finishes.>=A0> -- Lei= f Thanks Leif=2C this mostly makes sense - I am looking at the basic authoriz= ation plugin example (basic-auth.c) and I think I understand it.=A0It is in= tercepting calls and terminating some of them by not calling=A0TSHttpTxnRee= nable(txnp=2C TS_EVENT_HTTP_CONTINUE)=3B=A0in the cases where the authoriza= tion isn't found (as I understand it). I think I can add a hook to TS_HTTP_READ_REQUEST_HDR_HOOK and then have a c= ontinuation called back after a TSHttpConnect call. Can I then (based on the response) achieve the same results of remapping or= forwarding the response as I am doing in my remap plugin?TSUrlHostSet(...T= SUrlPathSet (...TSUrlHttpQuerySet (...(sometimes) rri->redirect =3D 1=3B and then=A0return TSREMAP_DID_REMAP thanks very much=2CServalan =