小编yos*_*aan的帖子

清漆C VRT变量/功能

我开始拿起清漆并在我们的配置中遇到了C代码中的VRT函数的引用(以及网上的示例),我找不到文档(据我所知,我的C知识是不存在的) .这是我能找到的最好的,但它只是原型:http://fossies.org/dox/varnish-4.0.2/vrt__obj_8h.html#a7b48e87e48beb191015eedf37489a290

所以这是我们使用的一个例子(这似乎是来自网络的copypasta,因为我发现它很多次):

C{
  #include <ctype.h>
  static void strtolower(char *c) {
    for (; *c; c++) {
      if (isupper(*c)) {
        *c = tolower(*c);
      }
    }
  }
}C

sub vcl_recv {
...stuff....
if (req.url ~ "<condition>" && (<another if condition>)) {
  C{
    strtolower((char *)VRT_r_req_url(sp));
  }C
}
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:

  1. 什么是sp?它从何而来?它没有在任何地方定义,也没有任何关于它的信息
  2. VRT_r_req_url做什么?为什么VRT_前缀和r是什么(我也看到VRT_l_函数).它从这个结构获取数据是什么?
  3. 所有这些VRT函数是否相似,以获得与C块之外的req.url相同的变量?
  4. 是否有文档说明所有这些都做了什么?例如,我也见过几次:

    sub detectmobile {
      C{
        VRT_SetHdr(sp, HDR_BEREQ, "\020X-Varnish-TeraWurfl:", "no1", vrt_magic_string_end);
      }C
     }
    
    Run Code Online (Sandbox Code Playgroud)

    那么这里的HDR_BEREQ和vrt_magic_string_end是什么?

c varnish varnish-vcl

3
推荐指数
1
解决办法
1312
查看次数

标签 统计

c ×1

varnish ×1

varnish-vcl ×1