From: phk Date: Mon, 2 Jul 2007 13:28:03 +0000 (+0000) Subject: Generate correct code for bereq.http and obj.http X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d39cac020f2ad8ab20291e58d164702123f937f3;p=varnish Generate correct code for bereq.http and obj.http git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1617 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index 391212d2..150e5b57 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -74,7 +74,7 @@ int VRT_rewrite(const char *, const char *); void VRT_error(struct sess *, unsigned, const char *); int VRT_switch_config(const char *); -enum gethdr_e { HDR_REQ, HDR_RESP }; +enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ }; char *VRT_GetHdr(struct sess *, enum gethdr_e where, const char *); void VRT_handling(struct sess *sp, unsigned hand); diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index b864afd5..d1776824 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -430,7 +430,7 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);\n"); vsb_cat(sb, "int VRT_switch_config(const char *);\n"); vsb_cat(sb, "\n"); - vsb_cat(sb, "enum gethdr_e { HDR_REQ, HDR_RESP };\n"); + vsb_cat(sb, "enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ };\n"); vsb_cat(sb, "char *VRT_GetHdr(struct sess *, enum gethdr_e where, const char *);\n"); vsb_cat(sb, "void VRT_handling(struct sess *sp, unsigned hand);\n"); vsb_cat(sb, "\n"); diff --git a/varnish-cache/lib/libvcl/vcc_var.c b/varnish-cache/lib/libvcl/vcc_var.c index eb9a522d..12e5a0b0 100644 --- a/varnish-cache/lib/libvcl/vcc_var.c +++ b/varnish-cache/lib/libvcl/vcc_var.c @@ -49,8 +49,11 @@ vcc_StringVal(struct tokenlist *tl) EncToken(tl->fb, tl->t); vcc_NextToken(tl); return; - } - ExpectErr(tl, VAR); + } else if (tl->t->tok != VAR) { + vsb_printf(tl->sb, "Expected string variable or constant\n"); + vcc_ErrWhere(tl, tl->t); + return; + } ERRCHK(tl); vp = vcc_FindVar(tl, tl->t, vcc_vars); ERRCHK(tl); @@ -88,18 +91,27 @@ HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh) memcpy(p, t->b, i); p[i] = '\0'; v->name = p; + v->access = V_RW; v->fmt = STRING; v->methods = vh->methods; if (!memcmp(vh->name, "req.", 4)) wh = "HDR_REQ"; else if (!memcmp(vh->name, "resp.", 5)) wh = "HDR_RESP"; + else if (!memcmp(vh->name, "obj.", 4)) + wh = "HDR_OBJ"; + else if (!memcmp(vh->name, "bereq.", 6)) + wh = "HDR_BEREQ"; else assert(0 == 1); asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", wh, (unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len); - assert(p != NULL); + AN(p); v->rname = p; + asprintf(&p, "VRT_SetHdr(sp, %s, \"\\%03o%s:\")", wh, + (unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len); + AN(p); + v->lname = p; return (v); }