• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

c语言ats修改max-age示例插件代码

c语言 海叔叔 4年前 (2021-12-13) 57次浏览 已收录 0个评论
文章目录[隐藏]

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


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:c语言ats修改max-age示例插件代码
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址