From 7b7d4920344412e95868ae13fad886a81215b622 Mon Sep 17 00:00:00 2001 From: cecilihf Date: Tue, 18 Sep 2007 11:40:44 +0000 Subject: [PATCH] Fixes #157. Always replace Date with current time on varnish server. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1955 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_response.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 06681d10..99663919 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -29,6 +29,8 @@ * $Id$ */ +#include +#include #include #include @@ -109,6 +111,8 @@ res_do_conds(struct sess *sp) void RES_BuildHttp(struct sess *sp) { + char *time_str; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (sp->obj->response == 200 && sp->http->conds && res_do_conds(sp)) @@ -121,6 +125,17 @@ RES_BuildHttp(struct sess *sp) http_CopyResp(sp->http, &sp->obj->http); http_FilterFields(sp->wrk, sp->fd, sp->http, &sp->obj->http, HTTPH_A_DELIVER); + + /* Replace Date header with current date instead of keeping the date + * originally given by the backend when the object was fetched (which + * could be a long time ago). + */ + http_Unset(sp->http, H_Date); + time_str = malloc(50); + sprintf(time_str, "Date: "); + TIM_format(TIM_real(), &(time_str[6])); + http_SetHeader(sp->wrk, sp->fd, sp->http, time_str); + if (sp->xid != sp->obj->xid) http_PrintfHeader(sp->wrk, sp->fd, sp->http, "X-Varnish: %u %u", sp->xid, sp->obj->xid); -- 2.39.5