[4.0] 7d633a3 Check for multiple Content-Length headers
Martin Blix Grydeland
martin at varnish-software.com
Fri Nov 7 14:17:23 CET 2014
commit 7d633a389db4adf23153ed788c34baef76224ae5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Oct 30 09:40:36 2014 +0000
Check for multiple Content-Length headers
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index f2998d4..1a77ec3 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -168,6 +168,25 @@ http_find_header(char * const *hh, const char *hdr)
}
/**********************************************************************
+ * count header
+ */
+
+static int
+http_count_header(char * const *hh, const char *hdr)
+{
+ int n, l, r = 0;
+
+ l = strlen(hdr);
+
+ for (n = 3; hh[n] != NULL; n++) {
+ if (strncasecmp(hdr, hh[n], l) || hh[n][l] != ':')
+ continue;
+ r++;
+ }
+ return (r);
+}
+
+/**********************************************************************
* Expect
*/
@@ -535,6 +554,9 @@ cmd_http_rxresp(CMD_ARGS)
"Unknown http rxresp spec: %s\n", *av);
http_rxhdr(hp);
http_splitheader(hp, 0);
+ if (http_count_header(hp->resp, "Content-Length") > 1)
+ vtc_log(hp->vl, 0,
+ "Multiple Content-Length headers.\n");
hp->body = hp->rxbuf + hp->prxbuf;
if (!has_obj)
return;
@@ -561,6 +583,9 @@ cmd_http_rxresphdrs(CMD_ARGS)
vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av);
http_rxhdr(hp);
http_splitheader(hp, 0);
+ if (http_count_header(hp->resp, "Content-Length") > 1)
+ vtc_log(hp->vl, 0,
+ "Multiple Content-Length headers.\n");
}
@@ -819,6 +844,9 @@ cmd_http_rxreq(CMD_ARGS)
vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av);
http_rxhdr(hp);
http_splitheader(hp, 1);
+ if (http_count_header(hp->req, "Content-Length") > 1)
+ vtc_log(hp->vl, 0,
+ "Multiple Content-Length headers.\n");
hp->body = hp->rxbuf + hp->prxbuf;
http_swallow_body(hp, hp->req, 0);
vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen);
@@ -839,6 +867,9 @@ cmd_http_rxreqhdrs(CMD_ARGS)
vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av);
http_rxhdr(hp);
http_splitheader(hp, 1);
+ if (http_count_header(hp->req, "Content-Length") > 1)
+ vtc_log(hp->vl, 0,
+ "Multiple Content-Length headers.\n");
}
static void
More information about the varnish-commit
mailing list