]> err.no Git - varnish/commitdiff
Implement correct handling of the Expect: header.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 19 Sep 2008 20:49:30 +0000 (20:49 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 19 Sep 2008 20:49:30 +0000 (20:49 +0000)
Fixes #309

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3206 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/default.vcl
varnish-cache/bin/varnishtest/tests/c00018.vtc [new file with mode: 0644]

index 097a739d8a928779fa4350b991eebd6a667c5c7c..63355b0125935b988fe7a446eaa305d14384cbe4 100644 (file)
@@ -889,6 +889,8 @@ static int
 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 @@ cnt_start(struct sess *sp)
 
        /* 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);
 }
index d55d9488e2eeeeebdaededf327bf105c344f64b7..febfa8b03a4172bc198b19a232d4fea38fde08f8 100644 (file)
@@ -49,10 +49,6 @@ sub vcl_recv {
         /* 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;
diff --git a/varnish-cache/bin/varnishtest/tests/c00018.vtc b/varnish-cache/bin/varnishtest/tests/c00018.vtc
new file mode 100644 (file)
index 0000000..558f550
--- /dev/null
@@ -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