You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1998/01/13 11:11:54 UTC

[contrib] gif89-expires-hack

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);



Re: [contrib] gif89-expires-hack

Posted by Rob Hartill <ro...@imdb.com>.
On Tue, 13 Jan 1998, Dean Gaudet wrote:

> This bug is still around in Mozilla/4.02.  Lame lame lame.

Idiots!.

Waaaay back, a netscape.com host blitz one of my servers with requests
from a 3.0 Mozilla (beta I think) for a banner ad. I blocked the host
and the owner was very nice about agreeing to make sure the developers
were told about the problem which I described correctly. Later I was
forwarded some internal netscape newsgroup exchanges where that same
person was insulting me for blocking him and encouraging someone else to
remove an IMDb link from the "what's cool" page.

I also sent a bug report through the usual channels. Clearly they
don't take bug reports seriously... I'm a "whiner" - their leaked
description.


> 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. 


--
Rob Hartill                              Internet Movie Database (Ltd)
http://www.moviedatabase.com/   .. a site for sore eyes.


Re: [contrib] gif89-expires-hack

Posted by Dirk-Willem van Gulik <Di...@jrc.it>.
+1 Works and does make a difference. Wow!

Although it now also affects my normal 89a gif's which
do not cycle. However looking at the graphics control
section (http://www.kiarchive.ru/pub/unix/graphics/
format/gif/gif89a.doc.Z) would require a lot of parsing
throguh the files. So perhaps a separate fake mime
type is needed to make the distinction.

DW.


On Tue, 13 Jan 1998, Dean Gaudet wrote:

> 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);
> 
> 
> 

http://cils.ceo.org                         http://enrm.ceo.org
dirkx@technologist.com                     Dirk.vanGulik@jrc.it
+39 332 78 0014       +39 332 78 9549       fax +39 332 78 9185
ISEI/ESBA;                     The Center For Earth Observation
Joint Research Centre of the European Communities, Ispra, Italy