r4245 - in branches/2.0/varnish-cache/bin: varnishd varnishtest/tests

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Sep 28 11:05:05 CEST 2009


Author: tfheen
Date: 2009-09-28 11:05:05 +0200 (Mon, 28 Sep 2009)
New Revision: 4245

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

Fixes #494



Modified: branches/2.0/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_http.c	2009-09-28 08:53:10 UTC (rev 4244)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_http.c	2009-09-28 09:05:05 UTC (rev 4245)
@@ -332,12 +332,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;
 

Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/r00494.vtc (from rev 4036, trunk/varnish-cache/bin/varnishtest/tests/r00494.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/r00494.vtc	                        (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/r00494.vtc	2009-09-28 09:05:05 UTC (rev 4245)
@@ -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 obj.http.bar = obj.http.foo;
+		remove obj.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