[Zope-dev] IE and Zope MIME type handling

Casey Duncan c.duncan@nlada.org
Mon, 22 Oct 2001 14:33:52 -0400


Problem: Getting Zope to properly detect MIME types of posted files

The current solution is to try the following methods:

1. See if the browser specified a type and if so, use it.
2. See if the file extension can be recognized and derive a mime-type from it
3. Do some inspection of the file data (limited to text files at present)

Obviously #1 is preferred, and anytime the browser supplies the mime type, 
method #2 and #3 are never used. However, I have found a problem with this. 
Sometimes, IE reports a mime-type of "application/octet-stream" on files that 
is doesn't know better about.

This specifically happens on WordPerfect files. Now, I am as shocked as you 
are that a competitor's file format would not be recognized by IE, however, 
difficult as this may be to believe, it appears to be true.

My proposed solution and change in behavior is to ignore the browser supplied 
type if it is "application/octet-stream" and use #2 and perhaps #3 in that 
case to delve in further. Obviously this may pose a problem for applications 
that rely on the mime-type for files with extensions that might otherwise 
indicate something else. But since this behavior seems restricted to IE 
(amongst the browsers I tested), I doubt it would cause harm or breakage.

Thoughts?

I will supply the necessary patches if there is no objection.

/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/