Commit ee9e8034 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add support for passing a HTTP header-identity to a VMOD function.

parent 384d6732
......@@ -576,6 +576,32 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym)
SkipToken(tl, ID);
if (*p != '\0')
SkipToken(tl, ',');
} else if (fmt == HEADER) {
const struct var *v;
sym = VCC_FindSymbol(tl, tl->t, SYM_NONE);
vcc_AddUses(tl, tl->t, sym->r_methods, "Not available");
ERRCHK(tl);
SkipToken(tl, ID);
if (sym == NULL) {
vsb_printf(tl->sb, "Symbol not found.\n");
vcc_ErrWhere(tl, tl->t);
return;
}
if (sym->kind != SYM_VAR) {
vsb_printf(tl->sb, "Wrong kind of symbol.\n");
vcc_ErrWhere(tl, tl->t);
return;
}
AN(sym->var);
v = sym->var;
if (v->http == NULL) {
vsb_printf(tl->sb,
"Variable not an HTTP header.\n");
vcc_ErrWhere(tl, tl->t);
return;
}
e1 = vcc_mk_expr(VOID, "%s, \"%s\"", v->http, v->hdr);
p += strlen(p) + 1;
} else {
vcc_expr0(tl, &e1, fmt);
ERRCHK(tl);
......
......@@ -58,7 +58,7 @@ ctypes = {
'REAL': "double",
'DURATION': "double",
'INT': "int",
'HEADER': "const char *",
'HEADER': "enum gethdr_e, const char *",
'PRIV_VCL': "struct vmod_priv *",
'PRIV_CALL': "struct vmod_priv *",
'VOID': "void",
......@@ -281,8 +281,8 @@ fh.write("\n");
fh.write(plist)
fc.write('#include "vcc_if.h"\n')
fc.write('#include "vrt.h"\n')
fc.write('#include "vcc_if.h"\n')
fc.write("\n");
fc.write("\n");
......
......@@ -33,6 +33,7 @@
#include "../../bin/varnishd/cache.h"
#include "vrt.h"
#include "vcc_if.h"
double __match_proto__()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment