]> err.no Git - varnish/commitdiff
Make pass mode work for POST requests. Solves ticket #47.
authorcecilihf <cecilihf@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 18 Oct 2007 13:38:45 +0000 (13:38 +0000)
committercecilihf <cecilihf@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 18 Oct 2007 13:38:45 +0000 (13:38 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2115 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_fetch.c

index c894f9587525f2be6dd5ef050bc11c653b5d3446..37e0298d6627c08fc300de847c326317ab269bb3 100644 (file)
@@ -261,6 +261,9 @@ Fetch(struct sess *sp)
        int mklen, is_head;
        struct http_conn htc[1];
        int i;
+       int content_length;
+       char hdr[20];
+       char *ptr;
 
        CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
        CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -287,6 +290,17 @@ Fetch(struct sess *sp)
                return (__LINE__);
        WRK_Reset(w, &vc->fd);
        http_Write(w, hp, 0);
+       
+       /* If a POST request was passed to fetch, we must send
+        * any pipelined bytes to the backend as well */
+       if (!strcmp(http_GetReq(sp->http), "POST")) {
+               sprintf(hdr, "%ccontent-length:", 15);
+               assert(http_GetHdr(sp->http, hdr, &ptr));
+               content_length = atoi(ptr);
+               if (sp->htc->pipeline.b != NULL && content_length > 0)
+                       WRK_Write(w, sp->htc->pipeline.b, content_length);
+       }
+       
        if (WRK_Flush(w)) {
                VBE_UpdateHealth(sp, vc, -1);
                VBE_ClosedFd(sp->wrk, vc);