r1995 - in branches/1.1: . bin/varnishd

des at projects.linpro.no des at projects.linpro.no
Sun Sep 23 15:20:12 CEST 2007


Author: des
Date: 2007-09-23 15:20:12 +0200 (Sun, 23 Sep 2007)
New Revision: 1995

Modified:
   branches/1.1/
   branches/1.1/bin/varnishd/cache_response.c
Log:
Merged revisions 1955,1984,1986-1989,1992-1994 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r1955 | cecilihf | 2007-09-18 13:40:44 +0200 (Tue, 18 Sep 2007) | 2 lines
  
  Fixes #157. Always replace Date with current time on varnish server.
........
  r1994 | des | 2007-09-23 15:18:50 +0200 (Sun, 23 Sep 2007) | 2 lines
  
  Unbreak header ordering.
........



Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
   + /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1984,1986-1989,1992-1994

Modified: branches/1.1/bin/varnishd/cache_response.c
===================================================================
--- branches/1.1/bin/varnishd/cache_response.c	2007-09-23 13:18:50 UTC (rev 1994)
+++ branches/1.1/bin/varnishd/cache_response.c	2007-09-23 13:20:12 UTC (rev 1995)
@@ -32,6 +32,9 @@
 #include <sys/types.h>
 #include <sys/time.h>
 
+#include <stdio.h>
+#include <stdlib.h>
+
 #include "shmlog.h"
 #include "heritage.h"
 #include "cache.h"
@@ -109,6 +112,8 @@
 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 +126,17 @@
 	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);




More information about the varnish-commit mailing list