httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [contrib] gif89-expires-hack
Date Tue, 13 Jan 1998 10:11:54 GMT
This bug is still around in Mozilla/4.02.  Lame lame lame.  The bug I'm
referring to is the one that causes the browser to re-request an animated
gif89a over and over if the response has an Expires... even if the Expires
is way in the future.  I get really tired of seeing my hit logs fill up
with a once-per-loop request from every broken browser out there. 

Here's my patch for it updated from 1.2. 

Dean

--- http_core.c.orig	Tue Jan 13 02:24:03 1998
+++ http_core.c	Tue Jan 13 02:24:43 1998
@@ -1893,6 +1893,31 @@
 	if (d->content_md5 & 1) {
 	    table_set (r->headers_out, "Content-MD5", ap_md5digest(r->pool, f));
 	}
+	/* Shameless hack: if the file to be sent is image/gif and
+	 * gif89-expires-hack is set then remove the Expires header.  This is
+	 * required because of a bug in Mozilla versions up through at least 4
+	 * which causes it to re-request the animation every loop.  You
+	 * probably want this in your config:
+	 *
+	 * BrowserMatch Mozilla/[0-4]\. gif89-expires-hack
+	 *
+	 * -djg
+	 */
+	if (r->content_type
+	    && strcasecmp (r->content_type, "image/gif") == 0
+	    && r->finfo.st_size > 6
+	    && table_get (r->subprocess_env, "gif89-expires-hack")) {
+#define GIF_HEADER_LEN	(6)
+	    char gif_header[ GIF_HEADER_LEN ];
+
+	    if (fread (gif_header, 1, GIF_HEADER_LEN, f) == GIF_HEADER_LEN
+		&& memcmp (gif_header, "GIF89a", GIF_HEADER_LEN) == 0) {
+		table_unset (r->headers_out, "Expires");
+		table_unset (r->headers_out, "Cache-Control");
+	    }
+	    fseek (f, 0L, SEEK_SET);
+#undef GIF_HEADER_LEN
+	}
 
 	rangestatus = set_byterange(r);
 	send_http_header (r);
@@ -1926,6 +1951,15 @@
 	    MD5Update(&context, (void *)mm, r->finfo.st_size);
 	    table_set (r->headers_out, "Content-MD5",
 		ap_md5contextTo64(r->pool, &context));
+	}
+	/* Shameless gif89-expires-hack, see above */
+	if (r->content_type
+	    && strcasecmp (r->content_type, "image/gif") == 0
+	    && table_get (r->subprocess_env, "gif89-expires-hack")
+	    && r->finfo.st_size > 6
+	    && memcmp (mm, "GIF89a", 6) == 0) {
+	    table_unset (r->headers_out, "Expires");
+	    table_unset (r->headers_out, "Cache-Control");
 	}
 
 	rangestatus = set_byterange(r);



Mime
View raw message