Hi there, I'm trying to develop a simple plugin for TS but I'm having trouble with some API functions. I'm using the 2.1.7 unstable version and noticed that there has been some pretty mayor changes in some functions since 2.1.5. Specifically I'm struggling with the use of TSHttpHdrTypeGet, which I've noticed has changed from prototype:
TSMLoc TSHttpHdrUrlGet (TSMBuffer bufp, TSMLoc req_hdr_loc); to prototype: TSReturnCode TSHttpHdrUrlGet(TSMBuffer bufp, TSMLoc obj, TSMLoc *locp); Now I suppose the new version just returns a success/failure code and the actual TSMLoc object we are looking is being referenced by locp (if return code is TS_SUCCESS). The problem is I have not been able to get anything useful from this function, furthermore the variable holding the return code can't be associated with either TS_SUCCESS or TS_ERROR. Here's a oversimplified version of what I am doing: --------------------------------------------------------------------------------------------------------------- cacheable(TSHttpTxn txnp){ TSMBuffer bufp; TSMLoc hdr_loc; TSMLoc url_loc; TSHttpType hdr_type; TSReturnCode retv = TS_SUCCESS; TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc); hdr_type = TSHttpHdrTypeGet(bufp,hdr_loc); switch(hdr_type){ case TS_HTTP_TYPE_REQUEST: url_loc = TSHttpHdrCreate(bufp); retv = TSHttpHdrUrlGet(bufp,hdr_loc,&url_loc); if(retv == TS_SUCCESS){ //print url } else if(retv == TS_ERROR){ // print error msg } else{ TSDebug("test-plugin","\t\tHttpHdrUrlGet returned : %d",retv); } default: //Default msg } } --------------------------------------------------------------------------------------------------------------- cacheable is a function called from within a continuation that is hooked to the TS state machine through a TS_HTTP_OS_DNS_HOOK. Apparently everything goes smooth as TSHttpTxnClientReqGet succesfully sets both bufp and hdr_loc correctly and the subsequent call to TSHttpHdrTypeGet correctly sets hdr_type to TS_HTTP_TYPE_REQUEST. But the problem arises as I try to check the value returned by TSHttpHdrUrlGet. To my surprise it falls on the second else and prints something like this: [Mar 30 18:22:43.060] Server {1105197376} DIAG: (test-plugin) HttpHdrUrlGet returned : -1292229864 I don't really know why this could be happening, since I checked the source code and verified that only TS_SUCCESS or TS_ERROR are to be returned. Of course, if from within the second else I make a call to TSUrlStringGet and pass the obtained url_loc I get a segmentation fault. Does someone know what I'm doing wrong here? Thanks Nelson R. Perez