]> err.no Git - varnish/commitdiff
Log the headers we store in the object under ObjHeader so that
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 31 Jul 2006 20:27:02 +0000 (20:27 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 31 Jul 2006 20:27:02 +0000 (20:27 +0000)
we don't get two confusing batches of TxHeader in the sessions logentries.

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

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/include/shmlog_tags.h

index 97c7658aee886b67e9397712d68618e499f3d511..f6e04a09e01b523f918a04a6e49710c9c89603ed 100644 (file)
@@ -66,7 +66,8 @@ struct http {
        char                    *f;             /* first (F)ree byte */
        char                    *e;             /* (E)nd of buffer */
 
-       unsigned                conds;          /* If-* headers present */
+       unsigned char           conds;          /* If-* headers present */
+       unsigned char           objlog;
 
        struct http_hdr         hd[MAX_HTTP_HDRS];
        unsigned                nhd;
index 9406458320d8d1a41779acfc468655381bfc3d54..ead22c108e21986d9cad569aa539f6264ad22d12 100644 (file)
@@ -222,8 +222,15 @@ FetchBody(struct sess *sp)
        if (http_GetHdr(vc->http, H_Last_Modified, &b))
                sp->obj->last_modified = TIM_parse(b);
 
+       /*
+        * We borrow the sessions workspace and http header for building the
+        * headers to store in the object, then copy them over there.
+        * The actual headers to reply with are built later on over in
+        * cache_response.c
+        */
        sp->http->f = sp->http->v;
        sp->http->nhd = HTTP_HDR_FIRST;
+       sp->http->objlog = 1;   /* log as SLT_ObjHeader */
        http_CopyResp(sp->fd, sp->http, vc->http);
        http_FilterHeader(sp->fd, sp->http, vc->http, HTTPH_A_INS);
        
@@ -234,10 +241,13 @@ FetchBody(struct sess *sp)
                        cls = fetch_chunked(sp, vc->fd, vc->http);
                else 
                        cls = fetch_eof(sp, vc->fd, vc->http);
-               http_PrintfHeader(sp->fd, sp->http, "Content-Length: %u", sp->obj->len);
+               http_PrintfHeader(sp->fd, sp->http,
+                   "Content-Length: %u", sp->obj->len);
        } else
                cls = 0;
+       sp->http->objlog = 0;
        http_CopyHttp(&sp->obj->http, sp->http);
+       sp->http->f = sp->http->v;
 
        if (http_GetHdr(vc->http, H_Connection, &b) && !strcasecmp(b, "close"))
                cls = 1;
index c9240f70527c5b9a4f359f6f13b6501092a7d25c..012425c1d28bcc435eeb67bc79ab0e339b7d0f1e 100644 (file)
@@ -22,6 +22,9 @@
 #define VSLH(ax, bx, cx, dx) \
        VSLR((ax), (bx), (cx)->hd[(dx)].b, (cx)->hd[(dx)].e);
 
+#define VSLHT(bx, cx, dx) \
+       VSLH((cx)->objlog ? SLT_ObjHeader : SLT_TxHeader, bx, cx, dx)
+
 /*--------------------------------------------------------------------*/
 
 void
@@ -588,7 +591,7 @@ http_copyheader(int fd, struct http *to, struct http *fm, unsigned n)
        if (to->nhd < MAX_HTTP_HDRS) {
                to->hd[to->nhd].b = fm->hd[n].b;
                to->hd[to->nhd].e = fm->hd[n].e;
-               VSLH(SLT_TxHeader, fd, to, to->nhd);
+               VSLHT(fd, to, to->nhd);
                to->nhd++;
        } else  {
                VSL_stats->losthdr++;
@@ -624,7 +627,7 @@ http_SetHeader(int fd, struct http *to, unsigned n, const char *hdr)
                n = to->nhd++;
        to->hd[n].b = (void*)(uintptr_t)hdr;
        to->hd[n].e = strchr(hdr, '\0');
-       VSLH(SLT_TxHeader, fd, to, n);
+       VSLHT(fd, to, n);
 }
 
 /*--------------------------------------------------------------------*/
@@ -646,7 +649,7 @@ http_PrintfHeader(int fd, struct http *to, const char *fmt, ...)
                to->hd[to->nhd].b = to->f;
                to->hd[to->nhd].e = to->f + n;
                to->f += n + 1;
-               VSLH(SLT_TxHeader, fd, to, to->nhd);
+               VSLHT(fd, to, to->nhd);
                to->nhd++;
        }
        va_end(ap);
index a77ac2de34e448323f5da47a93d2a9eef55f1cd0..2a0f83410aa71ca9c51eb61e3b97a22fb7feef56 100644 (file)
@@ -32,6 +32,7 @@ SLTM(URL)
 SLTM(Protocol)
 SLTM(RxHeader)
 SLTM(TxHeader)
+SLTM(ObjHeader)
 SLTM(LostHeader)
 SLTM(TTL)
 SLTM(VCL_acl)