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

NB: some of this commit sneaked into #2757

Fix http_GetHdrField() to use the correct RFC2616 syntax for tokens
and separators.

Fixes ticket #255.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2758 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a8cb329f
......@@ -269,22 +269,25 @@ http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char
h++;
continue;
}
/* Check for substrings before memcmp() */
if ((h + fl == e || vct_issepctl(h[fl])) &&
!memcmp(h, field, fl)) {
/* got it */
h += fl;
if (ptr != NULL) {
while (vct_issp(*h))
/* Skip whitespace, looking for '=' */
while (*h && vct_issp(*h))
h++;
if (*h == '=') {
h++;
while (vct_issp(*h))
while (*h && vct_issp(*h))
h++;
*ptr = h;
}
}
return (1);
}
/* Skip token */
while (*h && !vct_issepctl(*h))
h++;
}
......
......@@ -110,9 +110,9 @@ RFC2616_Ttl(const struct sess *sp, const struct http *hp, struct object *obj)
retirement_age = INT_MAX;
u1 = u2 = 0;
if (http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) ||
http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) {
AN(p);
if ((http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) ||
http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) &&
p != NULL {
u1 = strtoul(p, NULL, 0);
u2 = 0;
if (http_GetHdr(hp, H_Age, &p)) {
......
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