Commit bd7206af authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r4150: 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ério Schneider for the patch.

Fixes #529



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@4295 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 7e225e6e
......@@ -46,6 +46,7 @@ static void
res_do_304(struct sess *sp)
{
char lm[64];
char *p;
WSP(sp, SLT_Length, "%u", 0);
......@@ -60,6 +61,19 @@ res_do_304(struct sess *sp)
TIM_format(sp->obj->last_modified, lm);
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "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->http, "Cache-Control: %s", p);
if (http_GetHdr(sp->obj->http, H_Content_Location, &p))
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Content-Location: %s", p);
if (http_GetHdr(sp->obj->http, H_ETag, &p))
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "ETag: %s", p);
if (http_GetHdr(sp->obj->http, H_Expires, &p))
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Expires: %s", p);
if (http_GetHdr(sp->obj->http, H_Vary, &p))
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Vary: %s", p);
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Connection: %s",
sp->doclose ? "close" : "keep-alive");
sp->wantbody = 0;
......
......@@ -6,6 +6,7 @@ server s1 {
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 @@ client c1 {
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
......
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