r257 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Wed Jun 28 18:59:07 CEST 2006
Author: phk
Date: 2006-06-28 18:59:07 +0200 (Wed, 28 Jun 2006)
New Revision: 257
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Construct our own Content-length header, no matter which of the
three (straight, chunked, eof) modes we used to fetch the object.
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-28 16:58:21 UTC (rev 256)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-28 16:59:07 UTC (rev 257)
@@ -161,6 +161,7 @@
st->len += e - b;
v -= e - b;
u -= e - b;
+ sp->obj->len += e - b;
}
while (v > 0) {
i = read(fd, p, v);
@@ -169,6 +170,7 @@
v -= i;
u -= i;
p += i;
+ sp->obj->len += i;
}
}
}
@@ -210,6 +212,7 @@
p += e - b;
v -= e - b;
st->len += e - b;
+ sp->obj->len += e - b;
*p = '\0';
}
i = read(fd, p, v);
@@ -219,6 +222,7 @@
p += i;
v -= i;
st->len += i;
+ sp->obj->len += i;
}
if (st != NULL && stevedore->trim != NULL)
@@ -262,25 +266,17 @@
switch (http_GetStatus(hp)) {
case 200:
case 301:
- http_BuildSbuf(sp->fd, 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 = 1;
break;
case 304:
- http_BuildSbuf(sp->fd, 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;
- sp->obj->cacheable = 0;
- break;
default:
break;
}
@@ -295,6 +291,7 @@
if (sp->obj->cacheable)
EXP_Insert(sp->obj);
+ http_BuildSbuf(sp->fd, 3, w->sb, hp);
if (body) {
if (http_GetHdr(hp, "Content-Length", &b))
cls = fetch_straight(w, sp, fd, hp, b);
@@ -302,11 +299,13 @@
cls = fetch_chunked(w, sp, fd, hp);
else
cls = fetch_eof(w, sp, fd, hp);
+ sbuf_printf(w->sb, "Content-Length: %u\r\n", sp->obj->len);
} else
cls = 0;
+ sbuf_cat(w->sb, "\r\n");
+ sbuf_finish(w->sb);
+ sp->obj->header = strdup(sbuf_data(w->sb));
- http_BuildSbuf(sp->fd, 2, w->sb, hp);
-
vca_write_obj(sp, w->sb);
if (http_GetHdr(hp, "Connection", &b) && !strcasecmp(b, "close"))
More information about the varnish-commit
mailing list