]> err.no Git - varnish/commitdiff
Fixes #157. Always replace Date with current time on varnish server.
authorcecilihf <cecilihf@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 18 Sep 2007 11:40:44 +0000 (11:40 +0000)
committercecilihf <cecilihf@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 18 Sep 2007 11:40:44 +0000 (11:40 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1955 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_response.c

index 06681d10d1226e6b26af45a4d99a52444cbb8182..99663919ab7407bd9c9ef75d64274a186d63fbc1 100644 (file)
@@ -29,6 +29,8 @@
  * $Id$
  */
 
+#include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/time.h>
 
@@ -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);