Commit e698fecb authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Log the headers we store in the object under ObjHeader so that

we don't get two confusing batches of TxHeader in the sessions logentries.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@575 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e638da9d
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -32,6 +32,7 @@ SLTM(URL)
SLTM(Protocol)
SLTM(RxHeader)
SLTM(TxHeader)
SLTM(ObjHeader)
SLTM(LostHeader)
SLTM(TTL)
SLTM(VCL_acl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment