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

phk at projects.linpro.no phk at projects.linpro.no
Fri Sep 19 22:49:30 CEST 2008


Author: phk
Date: 2008-09-19 22:49:30 +0200 (Fri, 19 Sep 2008)
New Revision: 3206

Added:
   trunk/varnish-cache/bin/varnishtest/tests/c00018.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/default.vcl
Log:
Implement correct handling of the Expect: header.

Fixes #309



Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2008-09-19 20:47:32 UTC (rev 3205)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2008-09-19 20:49:30 UTC (rev 3206)
@@ -889,6 +889,8 @@
 cnt_start(struct sess *sp)
 {
 	int done;
+	char *p;
+	const char *r = "HTTP/1.1 100 Continue\r\n\r\n";
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	AZ(sp->restarts);
@@ -929,6 +931,21 @@
 
 	/* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */
 
+	/*
+	 * Handle Expect headers
+	 */
+	if (http_GetHdr(sp->http, H_Expect, &p)) {
+		if (strcmp(p, "100-continue")) {
+			sp->err_code = 417;
+			sp->step = STP_ERROR;
+			return (0);
+		}
+
+		/* XXX: Don't bother with write failures for now */
+		(void)write(sp->fd, r, strlen(r));
+		http_Unset(sp->http, H_Expect);
+	}
+
 	sp->step = STP_RECV;
 	return (0);
 }

Modified: trunk/varnish-cache/bin/varnishd/default.vcl
===================================================================
--- trunk/varnish-cache/bin/varnishd/default.vcl	2008-09-19 20:47:32 UTC (rev 3205)
+++ trunk/varnish-cache/bin/varnishd/default.vcl	2008-09-19 20:49:30 UTC (rev 3206)
@@ -49,10 +49,6 @@
         /* Non-RFC2616 or CONNECT which is weird. */
         pipe;
     }
-    if (req.http.Expect) {
-        /* Expect is just too hard at present. */
-        pipe;
-    }
     if (req.request != "GET" && req.request != "HEAD") {
         /* We only deal with GET and HEAD by default */
         pass;

Added: trunk/varnish-cache/bin/varnishtest/tests/c00018.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/c00018.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/c00018.vtc	2008-09-19 20:49:30 UTC (rev 3206)
@@ -0,0 +1,21 @@
+# $Id$
+
+test "Check Expect headers"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend { } -start
+
+client c1 {
+	txreq -url "/" -req POST -hdr "Expect: 100-continue " -body "foo"
+	rxresp
+	expect resp.status == 100
+	rxresp
+	expect resp.status == 200
+	txreq -url "/" -req POST -hdr "Expect: 101-continue" -body "foo"
+	rxresp
+	expect resp.status == 417
+} -run




More information about the varnish-commit mailing list