]> err.no Git - varnish/commitdiff
304's don't have a body
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 28 Jun 2006 10:31:29 +0000 (10:31 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 28 Jun 2006 10:31:29 +0000 (10:31 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@246 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_fetch.c

index e00139dcfbfe4dee294ead326d68d208321ced69..06aed1c26b5e216996c485940d524c77bdf8986e 100644 (file)
@@ -67,16 +67,7 @@ fetch_straight(struct worker *w, struct sess *sp, int fd, struct http *hp, char
                p += i;
                cl -= i;
        }
-
-       http_BuildSbuf(2, w->sb, hp);
-
-       vca_write_obj(sp, w->sb);
-
-#if 0
-       hash->deref(sp->obj);
-#endif
        return (0);
-
 }
 
 /*--------------------------------------------------------------------*/
@@ -184,10 +175,6 @@ fetch_chunked(struct worker *w, struct sess *sp, int fd, struct http *hp)
 
        if (st != NULL && stevedore->trim != NULL)
                stevedore->trim(st, st->len);
-
-       http_BuildSbuf(2, w->sb, hp);
-
-       vca_write_obj(sp, w->sb);
        return (0);
 }
 
@@ -237,9 +224,6 @@ fetch_eof(struct worker *w, struct sess *sp, int fd, struct http *hp)
        if (st != NULL && stevedore->trim != NULL)
                stevedore->trim(st, st->len);
 
-       http_BuildSbuf(2, w->sb, hp);
-
-       vca_write_obj(sp, w->sb);
        return (1);
 }
 
@@ -252,6 +236,7 @@ FetchSession(struct worker *w, struct sess *sp)
        struct http *hp;
        char *b;
        time_t t_req, t_resp;
+       int body;
 
        fd = VBE_GetFd(sp->backend, &fd_token);
        assert(fd != -1);
@@ -282,6 +267,15 @@ FetchSession(struct worker *w, struct sess *sp)
                sp->obj->valid = 1;
                sp->obj->cacheable = 1;
                sp->obj->header = strdup(sbuf_data(w->sb));
+               body = 1;
+               break;
+       case 304:
+               http_BuildSbuf(3, w->sb, hp);
+               /* XXX: fill in object from headers */
+               sp->obj->valid = 1;
+               sp->obj->cacheable = 1;
+               sp->obj->header = strdup(sbuf_data(w->sb));
+               body = 0;
                break;
        case 391:
                sp->obj->valid = 0;
@@ -301,12 +295,19 @@ FetchSession(struct worker *w, struct sess *sp)
        if (sp->obj->cacheable)
                EXP_Insert(sp->obj);
 
-       if (http_GetHdr(hp, "Content-Length", &b))
-               cls = fetch_straight(w, sp, fd, hp, b);
-       else if (http_HdrIs(hp, "Transfer-Encoding", "chunked"))
-               cls = fetch_chunked(w, sp, fd, hp);
-       else 
-               cls = fetch_eof(w, sp, fd, hp);
+       if (body) {
+               if (http_GetHdr(hp, "Content-Length", &b))
+                       cls = fetch_straight(w, sp, fd, hp, b);
+               else if (http_HdrIs(hp, "Transfer-Encoding", "chunked"))
+                       cls = fetch_chunked(w, sp, fd, hp);
+               else 
+                       cls = fetch_eof(w, sp, fd, hp);
+       } else
+               cls = 0;
+
+       http_BuildSbuf(2, w->sb, hp);
+
+       vca_write_obj(sp, w->sb);
 
        if (http_GetHdr(hp, "Connection", &b) && !strcasecmp(b, "close"))
                cls = 1;