r4036 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at projects.linpro.no phk at projects.linpro.no
Mon Apr 27 12:32:23 CEST 2009


Author: phk
Date: 2009-04-27 12:32:23 +0200 (Mon, 27 Apr 2009)
New Revision: 4036

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00494.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Implement HTTP continuation lines.

Fixes #494



Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2009-04-27 10:03:53 UTC (rev 4035)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2009-04-27 10:32:23 UTC (rev 4036)
@@ -326,12 +326,29 @@
 	hp->conds = 0;
 	r = NULL;		/* For FlexeLint */
 	for (; p < t.e; p = r) {
-		/* XXX: handle continuation lines */
-		q = strchr(p, '\n');
-		assert(q != NULL);
-		r = q + 1;
-		if (q > p && q[-1] == '\r')
-			q--;
+
+		/* Find end of next header */
+		q = r = p;
+		while (r < t.e) {
+			if (!vct_iscrlf(*r)) {
+				r++;
+				continue;
+			}
+			q = r;
+			assert(r < t.e);
+			r += vct_skipcrlf(r);
+			if (r >= t.e)
+				break;
+			/* If line does not continue: got it. */
+			if (!vct_issp(*r))
+				break;
+
+			/* Clear line continuation LWS to spaces */
+			while (vct_islws(*q))
+				*q++ = ' ';
+		}
+
+		/* Empty header = end of headers */
 		if (p == q)
 			break;
 

Added: trunk/varnish-cache/bin/varnishtest/tests/r00494.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00494.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00494.vtc	2009-04-27 10:32:23 UTC (rev 4036)
@@ -0,0 +1,27 @@
+# $Id$
+
+test "HTTP continuation lines"
+
+#NB: careful about spaces and tabs in this test.
+
+server s1 {
+	rxreq
+	txresp -hdr {Foo: bar,
+	barf: fail} -body "xxx"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_fetch {
+		set beresp.http.bar = beresp.http.foo;
+		remove beresp.http.foo;
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.http.bar == "bar,  barf: fail"
+	expect resp.http.barf == resp.http.barf
+	expect resp.http.foo == resp.http.foo
+} -run
+



More information about the varnish-commit mailing list