c语言ats修改max-age示例插件代码
关键词:c语言,ats插件
#include <stdio.h> #include <string.h> #include <ctype.h> #include "ts/ts.h" #include "/root/trafficserver/lib/ts/ink_defs.h" #define PLUGIN_NAME "stacache" static void cache_lookup(TSHttpTxn txnp) { //TSCacheUrlSet(TSHttpTxn txnp, const char* url, int length); int st = TS_CACHE_LOOKUP_MISS; if(TSHttpTxnCacheLookupStatusGet(txnp, &st) != TS_SUCCESS) { goto done; } TSDebug(PLUGIN_NAME,"cache lookup result:%d",st); done: TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); } static int cache_lookup_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata) { TSHttpTxn txnp = (TSHttpTxn) edata; switch (event) { case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE: cache_lookup(txnp); return 0; default: break; } return 0; } void TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED) { TSPluginRegistrationInfo info; info.plugin_name = "stacache"; info.vendor_name = "stateam"; info.support_email = "sta-team"; if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) { TSError("Plugin registration failed. \n"); } TSCont contp = TSContCreate(cache_lookup_plugin, NULL); TSHttpHookAdd(TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, contp); }
来源搞代码网《c语言ats修改max-age示例插件代码》http://www.gaodaima.com/68556.html