> On 4/4/12 6:36 AM, 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 decide how to 
> handle the requests.> > I've coded this up using libcurl, which works but 
> seems very slow - creating and destroying a curl_easy_init object per call. 
> Is there a way to call an HTTP GET during a plugin's process, just passing 
> some request parameters and headers using the internal ATSfunctionality? > > 
> It seems TSFetchRespGet or TSFetchURL might work, but I can't see any way to 
> make a new tsapi_httptxn with my call in it.> > thanks very much,> > > > 
> Yeah, none of this will work (well) in a remap plugin. You need to > rewrite 
> this as e.g. a read-request-header hook, and then use > TSHttpConnect() (most 
> likely) to fetch the content. This also implies > you have to yield and 
> reschedule your continuation while waiting and > processing the response. If 
> not (and as you probably have noticed with > your remap plugin), you will 
> block the net-thread for the duration of > the request. This is very bad, 
> because all clients on that thread are > now stalled until your (curl) 
> request finishes.> > -- Leif

Thanks Leif, this mostly makes sense - I am looking at the basic authorization 
plugin example (basic-auth.c) and I think I understand it. It is intercepting 
calls and terminating some of them by not calling TSHttpTxnReenable(txnp, 
TS_EVENT_HTTP_CONTINUE); in the cases where the authorization 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 
continuation 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(...TSUrlPathSet (...TSUrlHttpQuerySet (...(sometimes) 
rri->redirect = 1;
and then return TSREMAP_DID_REMAP
thanks very much,Servalan
                                          

Reply via email to