a jaundiced eye: stuck
for thursday, may 15, 1997.

How to Kill Your Web Browser.

So I went to a page here at Jaundiced Eye which doesn't exist. Ordinarily, this wouldn't be a problem, as the server would simply generate a 404 Not Found error. What could be simpler?

However, JE is served from an Apache server, which is capable of trapping errors, such as 404, and responding in less jarring ways. I had configured JE's server to send back a certain page whenever I got a 404 - the page explains that the URL is not correct, and offers advice on how to find what you're looking for. Real nice. I recommend it to anyone who wants to provide a somewhat personalized experience for your fumble-fingered web visitors.

In this case, however, I had used a frameset document for the page which was returned. Since the 404 ErrorDocument is a rooted URL, the server knows how to find the page it needs to send back to the browser. Unfortunately, the browser is not sent a HTTP Redirect, but is sent the contents of the file named in the ErrorDocument config.

What this means is that if my ErrorDocument is defined thus:

  ErrorDocument 404 /toc_error.html

But I went looking for

  http://www.jaundicedeye.com/no/such/file.html
The browser would think that the document returned is actually /no/such/file.html. Not a big deal when you're using a single test page, with no external references. But this doc is a frameset, which contained references to other HTML files, which contained references to images, and so on.

The kicker comes when the HREFs are not rooted, in other words, when the anchors and FRAME SRCs look like this:

 <FRAME SRC="toc_errror_body.html">

If you've been folowing along, you'll realize the problem. The browser thinks it is dealing with /no/such/file.html. It parses the frameset, and tries to fetch the file /no/such/toc_error_body.html - which of course, doesn't exist. Which generates another 404. Which sends back another copy of the toc_error frameset document. Ever heard of recursion?

I've seen Navigator crash before, but this was pretty spectacular. BTW, it crashed on both Macintosh 3.* and Win95 3.* before I figured out what the hell was causing it...

THE MORAL:

If you're sending back a frameset from your handy ErrorDocument redirect (or, presumably, any other HTTP error) be sure to use rooted HREFs and SRCs - else you'll throw your browser into such a tailspin you'll never see anything like it. Pretty cool to watch, but I don't recommend it for parties.

THE UPSHOT:

Perhaps the kind folks at Apache would like to consider using a 302 Moved Temporarily HTTP header to send back the appropriate URL in the case of the following config:

ErrorDocument 404 /some/rooted/relative/url.html

Thanks to the Web for the entertainment.

Steven Champeon





r e c i p r o c a t e


Permanently archived at: http://www.jaundicedeye.com/browse/stuck/051697/

© 1997-2001 Steven Champeon. All rights reserved.
All slights reversed.