Commit eadcc45e authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Ignore leading spaces in http_CollectHdr

The default separator is now ", " to maintain the "pretty collapsing" of
the headers without risking an extra space with the "; " separator for
cookies.

Refs #2291
Refs #2292
parent 58b2d306
......@@ -343,13 +343,14 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
{
unsigned u, l, lsep, ml, f, x, d;
char *b = NULL, *e = NULL;
const char *v;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
if (WS_Overflowed(hp->ws))
return;
if (sep == NULL || *sep == '\0')
sep = ",";
sep = ", ";
lsep = strlen(sep);
l = hdr[0];
......@@ -390,6 +391,13 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
/* Append the Nth header we found */
x = Tlen(hp->hd[u]) - l;
v = hp->hd[u].b + *hdr;
while (vct_issp(*v)) {
v++;
x--;
}
if (b + lsep + x >= e) {
http_fail(hp);
VSLb(hp->vsl, SLT_LostHeader, "%s", hdr + 1);
......@@ -398,7 +406,7 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
}
memcpy(b, sep, lsep);
b += lsep;
memcpy(b, hp->hd[u].b + *hdr, x);
memcpy(b, v, x);
b += x;
}
if (b == NULL)
......
......@@ -13,7 +13,7 @@ logexpect l1 -v v1 {
expect * = BereqHeader "Cookie: user=alice"
expect * = BereqHeader "Cookie: peer=bob"
expect * * BereqProtocol HTTP/2.0
expect * = BereqHeader "cookie: user=alice; peer=bob"
expect * = BereqHeader "cookie: user=alice; peer=bob"
} -start
client c1 {
......
......@@ -107,7 +107,7 @@ Description
Example
set beresp.http.served-by = std.fileread("/etc/hostname");
$Function VOID collect(HEADER hdr, STRING sep=",")
$Function VOID collect(HEADER hdr, STRING sep=", ")
Description
Collapses multiple *hdr* headers into one long header.
......
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