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

Generate correct code for bereq.http and obj.http


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1617 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent c8a967ca
...@@ -74,7 +74,7 @@ int VRT_rewrite(const char *, const char *); ...@@ -74,7 +74,7 @@ int VRT_rewrite(const char *, const char *);
void VRT_error(struct sess *, unsigned, const char *); void VRT_error(struct sess *, unsigned, const char *);
int VRT_switch_config(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 *); char *VRT_GetHdr(struct sess *, enum gethdr_e where, const char *);
void VRT_handling(struct sess *sp, unsigned hand); void VRT_handling(struct sess *sp, unsigned hand);
......
...@@ -430,7 +430,7 @@ vcl_output_lang_h(struct vsb *sb) ...@@ -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, "void VRT_error(struct sess *, unsigned, const char *);\n");
vsb_cat(sb, "int VRT_switch_config(const char *);\n"); vsb_cat(sb, "int VRT_switch_config(const char *);\n");
vsb_cat(sb, "\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, "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, "void VRT_handling(struct sess *sp, unsigned hand);\n");
vsb_cat(sb, "\n"); vsb_cat(sb, "\n");
......
...@@ -49,8 +49,11 @@ vcc_StringVal(struct tokenlist *tl) ...@@ -49,8 +49,11 @@ vcc_StringVal(struct tokenlist *tl)
EncToken(tl->fb, tl->t); EncToken(tl->fb, tl->t);
vcc_NextToken(tl); vcc_NextToken(tl);
return; return;
} } else if (tl->t->tok != VAR) {
ExpectErr(tl, VAR); vsb_printf(tl->sb, "Expected string variable or constant\n");
vcc_ErrWhere(tl, tl->t);
return;
}
ERRCHK(tl); ERRCHK(tl);
vp = vcc_FindVar(tl, tl->t, vcc_vars); vp = vcc_FindVar(tl, tl->t, vcc_vars);
ERRCHK(tl); ERRCHK(tl);
...@@ -88,18 +91,27 @@ HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh) ...@@ -88,18 +91,27 @@ HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh)
memcpy(p, t->b, i); memcpy(p, t->b, i);
p[i] = '\0'; p[i] = '\0';
v->name = p; v->name = p;
v->access = V_RW;
v->fmt = STRING; v->fmt = STRING;
v->methods = vh->methods; v->methods = vh->methods;
if (!memcmp(vh->name, "req.", 4)) if (!memcmp(vh->name, "req.", 4))
wh = "HDR_REQ"; wh = "HDR_REQ";
else if (!memcmp(vh->name, "resp.", 5)) else if (!memcmp(vh->name, "resp.", 5))
wh = "HDR_RESP"; wh = "HDR_RESP";
else if (!memcmp(vh->name, "obj.", 4))
wh = "HDR_OBJ";
else if (!memcmp(vh->name, "bereq.", 6))
wh = "HDR_BEREQ";
else else
assert(0 == 1); assert(0 == 1);
asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", wh, asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", wh,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len); (unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
assert(p != NULL); AN(p);
v->rname = 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); return (v);
} }
......
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