r241 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Jun 26 21:24:03 CEST 2006


Author: phk
Date: 2006-06-26 21:24:03 +0200 (Mon, 26 Jun 2006)
New Revision: 241

Modified:
   trunk/varnish-cache/bin/varnishd/rfc2616.c
Log:
A temporary hack to deal with very old Date: headers until we figure
out what's going on.



Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/rfc2616.c	2006-06-26 19:23:24 UTC (rev 240)
+++ trunk/varnish-cache/bin/varnishd/rfc2616.c	2006-06-26 19:24:03 UTC (rev 241)
@@ -42,6 +42,7 @@
 	time_t apparent_age = 0, corrected_received_age;
 	time_t response_delay, corrected_initial_age;
 	time_t max_age = -1, ttl;
+	time_t fudge;
 	char *p;
 
 	if (http_GetHdrField(hp, "Cache-Control", "max-age", &p))
@@ -50,6 +51,12 @@
 	if (http_GetHdr(hp, "Date", &p))
 		h_date = TIM_parse(p);
 
+	if (h_date + 3600 < t_resp) {
+		fudge = t_resp - h_date;
+		h_date += fudge;
+	} else
+		fudge = 0;
+
 	if (h_date < t_resp)
 		apparent_age = t_resp - h_date;
 
@@ -64,8 +71,9 @@
 	response_delay = t_resp - t_req;
 	corrected_initial_age = corrected_received_age + response_delay;
 
-	if (http_GetHdr(hp, "Expires", &p))
-		h_expires = TIM_parse(p);
+	if (http_GetHdr(hp, "Expires", &p)) {
+		h_expires = TIM_parse(p) + fudge;
+	}
 
 	printf("Date: %d\n", h_date);
 	printf("Recv: %d\n", t_resp);




More information about the varnish-commit mailing list