r4150 - in trunk/varnish-cache/bin: varnishd varnishtest/tests
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Tue Jul 28 15:42:39 CEST 2009
Author: tfheen
Date: 2009-07-28 15:42:38 +0200 (Tue, 28 Jul 2009)
New Revision: 4150
Modified:
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc
Log:
Emit more headers when hitting 304
When hitting 304, ETag, Content-Location, Expires, Cache-control and
Vary should all be sent to the client.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
for some more details
Thanks to Rog?\195?\169rio Schneider for the patch.
Fixes #529
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2009-07-28 13:30:49 UTC (rev 4149)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2009-07-28 13:42:38 UTC (rev 4150)
@@ -47,6 +47,7 @@
res_do_304(struct sess *sp)
{
char lm[64];
+ char *p;
WSP(sp, SLT_Length, "%u", 0);
@@ -61,6 +62,19 @@
TIM_format(sp->obj->last_modified, lm);
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Last-Modified: %s", lm);
}
+
+ /* http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5 */
+ if (http_GetHdr(sp->obj->http, H_Cache_Control, &p))
+ http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Cache-Control: %s", p);
+ if (http_GetHdr(sp->obj->http, H_Content_Location, &p))
+ http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Content-Location: %s", p);
+ if (http_GetHdr(sp->obj->http, H_ETag, &p))
+ http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "ETag: %s", p);
+ if (http_GetHdr(sp->obj->http, H_Expires, &p))
+ http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Expires: %s", p);
+ if (http_GetHdr(sp->obj->http, H_Vary, &p))
+ http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Vary: %s", p);
+
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Connection: %s",
sp->doclose ? "close" : "keep-alive");
sp->wantbody = 0;
Modified: trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc 2009-07-28 13:30:49 UTC (rev 4149)
+++ trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc 2009-07-28 13:42:38 UTC (rev 4150)
@@ -6,6 +6,7 @@
rxreq
expect req.url == "/foo"
txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+ -hdr "ETag: foo" \
-body "11111\n"
} -start
@@ -15,22 +16,26 @@
txreq -url "/foo"
rxresp
expect resp.status == 200
+ expect resp.http.etag == "foo"
expect resp.http.content-length == 6
txreq -url "/foo" \
-hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT"
rxresp
expect resp.status == 200
+ expect resp.http.etag == "foo"
txreq -url "/foo" \
-hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT"
rxresp
expect resp.status == 304
+ expect resp.http.etag == "foo"
txreq -url "/foo" \
-hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:02 GMT"
rxresp
expect resp.status == 304
+ expect resp.http.etag == "foo"
}
client c1 -run
More information about the varnish-commit
mailing list