我开始拿起清漆并在我们的配置中遇到了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)
所以我的问题是:
是否有文档说明所有这些都做了什么?例如,我也见过几次:
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是什么?