Commit b2190582 authored by Joshua Bussdieker's avatar Joshua Bussdieker

Request must match their own Key header rules to get saved.

parent 0e07764e
......@@ -315,7 +315,9 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
VSLb(bo->vsl, SLT_Error,
"Illegal 'Key' header from backend, "
"making this a pass.");
bo->uncacheable = 1;
// We're willing to try again
bo->exp.ttl = 0;
AZ(key);
} else {
#endif
......
......@@ -376,7 +376,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
#ifdef KEY_HEADER
if (oc->busyobj != NULL &&
oc->busyobj->key != NULL &&
!KEY_Match(req, oc->busyobj->key))
!KEY_Match(req->http, oc->busyobj->key))
continue;
#endif
......@@ -397,7 +397,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
if (BAN_CheckObject(o, req))
continue;
#ifdef KEY_HEADER
if (o->key != NULL && !KEY_Match(req, o->key))
if (o->key != NULL && !KEY_Match(req->http, o->key))
continue;
#endif
if (o->vary != NULL && !VRY_Match(req, o->vary))
......
......@@ -244,6 +244,12 @@ KEY_Create(struct busyobj *bo, struct vsb **psb)
VSB_delete(sbh);
AZ(VSB_finish(sb));
if (KEY_Match(bo->bereq, VSB_data(sb)) == 0) {
printf("That doesn't match this req wth\n");
return -1;
}
*psb = sb;
DEBUG && printf("KEY_Create(bo: %p, psb: %p) = %zu\n", bo, *psb, VSB_len(sb));
DEBUG && hexDump("key", VSB_data(sb), VSB_len(sb));
......@@ -279,9 +285,9 @@ int word_match(char *param, char *string) {
}
int
KEY_Match(struct req *req, const uint8_t *key)
KEY_Match(struct http *http, const uint8_t *key)
{
DEBUG && printf("KEY_Match(req: %p, key: %p)\n", req, key);
DEBUG && printf("KEY_Match(http: %p, key: %p)\n", http, key);
char *h;
int i;
......@@ -297,7 +303,7 @@ KEY_Match(struct req *req, const uint8_t *key)
DEBUG && printf(" Header (Exact): %s\n", key + 4);
i = http_GetHdr(req->http, (const char*)(key+3), &h);
i = http_GetHdr(http, (const char*)(key+3), &h);
if (l == 0xFFFF) {
// Expect missing
......@@ -351,7 +357,7 @@ KEY_Match(struct req *req, const uint8_t *key)
char *e;
unsigned l = vbe16dec(key);
i = http_GetHdr(req->http, (const char*)(key+3), &h);
i = http_GetHdr(http, (const char*)(key+3), &h);
// TODO: Perhaps not matcher should allow this
if (i == 0)
......@@ -381,6 +387,6 @@ KEY_Match(struct req *req, const uint8_t *key)
key += key_len(key);
}
DEBUG && printf("KEY_Match(req: %p, key: %p) = 1\n", req, key);
DEBUG && printf("KEY_Match(http: %p, key: %p) = 1\n", http, key);
return 1;
}
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