[Zope] Mime type for PNG

Bruce Elrick belrick@home.com
Sat, 13 Nov 1999 00:06:40 -0700


Chris McDonough wrote:
> 
> Bruce Elrick wrote:
> >
> > In trying to view my site with Opera, I noticed that my PNG images (named with
> > blah_blah_png) are send with a Mime type of image/x-png, not image/png.  I
> > can't figure out how to get opera to recognize this as a PNG (it apparently
> > handles PNG with image/png, since it does have it defined).
> 
> Using Zope 2.0.1 under Linux, I can't replicate this...
> 
> a sample transaction (localhost/goopy_png_png is a png image I generated
> using GIMP):
> 
> [mcdonc@cindy mcdonc]$ telnet localhost 8080
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> HEAD /goopy_png_png HTTP/1.0
> 
> HTTP/1.0 200 OK
> Server: Zope/(unreleased version) ZServer/1.1b1
> Date: Sat, 13 Nov 1999 04:56:38 GMT
> Ms-Author-Via: DAV
> Content-Type: image/png
> Connection: close
> Date: Sat, 13 Nov 1999 04:56:38 GMT
> Connection: close
> Content-Length: 1338
> Last-Modified: Sat, 13 Nov 1999 04:56:16 GMT
> 
> What Zope version are you using?  What is your configuration?
> 
> --
> Chris McDonough
> Digital Creations, Inc.
> Zope - http://www.zope.org

I'm using Zope 2.0.1 from source, Python 1.5.2 from Redhat 6.1, IBM's Apache
based web server, rewrite rules:
RewriteEngine On
RewriteLog logs/rewrite_log
RewriteLogLevel 0
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^/Zope(.*) /opt/IBMHTTPServer/cgi-bin/Zope.cgi$1
[e=HTTP_CGI_AUTHORIZATION:%1,t=application/x-httpd-cgi,l]

Here is a duplication of your experiment:

$ telnet fred 80
Trying 192.168.1.1...
Connected to fred.saltus.
Escape character is '^]'.
HEAD /Zope/Graphics/logoname_Saltus_200x48_png HTTP/1.0

HTTP/1.1 200 OK
Date: Sat, 13 Nov 1999 06:23:55 GMT
Server: IBM_HTTP_Server/1.3.6 Apache/1.3.7-dev
Connection: close
Ms-Author-Via: DAV
X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Content-Length: 1180
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: image/x-png

Connection closed by foreign host.

Note that My Linux based Netscape 4.7 has both image/png and image/x-png
supported.  I assume the latter is from the early days of the png
scpecification before it got an official MIME type.

For your digestion, I'll also include (from the Zope directory):
# find . -name '*.py' -exec grep -i png {} \; -print
    """Image objects can be GIF, PNG or JPEG and have the same methods
        # handle PNGs
        # Re: PNG v1.2 spec (http://www.cdrom.com/pub/png/spec/)
        elif (size >= 24) and (data[:8] == '\211PNG\r\n\032\n') \
        # Maybe this is for an older PNG version.
        elif (size >= 16) and (data[:8] == '\x89PNG\r\n\x1a\n'):
./OFS/Image.py
            'image/x-png':     'PNG Image',
./Products/Confera/FileObject.py
            'image/x-png':     'PNG Image',
./Products/Squishdot/Squishfile.py

and for the IBM/Apache web server:
# grep -i png /opt/IBMHTTPServer/conf/*
/opt/IBMHTTPServer/conf/mime.types:image/png                    png
/opt/IBMHTTPServer/conf/mime.types.default:image/png                    png

I checked my RPM's and I had Zope 1.10.3 as an RPM and that RPM put Zope .py
files in /usr/lib/python1.5/site-packages, so I thought that might be an
issue.  I just removed that RPM (as well as the old zserver RPM) and recycled
Zope.  Same result.

I did some more digging and found that in python1.5/mimetypes.py, it has:
knownfiles = [
    "/usr/local/etc/httpd/conf/mime.types",
    "/usr/local/lib/netscape/mime.types",
    "/usr/local/etc/httpd/conf/mime.types",     # Apache 1.2
    "/usr/local/etc/mime.types",                # Apache 1.3
    ]
and loads extra mime types from there.  None of those files exist on my
system.

So, is the Confera code 'polluting' the PNG Mime type waters?

Cheers and thanks...
Bruce
--
Bruce Elrick, Ph.D.                       Saltus Technology Consulting Group
Personal: belrick@home.com                          IBM Certified Specialist
Business: belrick@saltus.ab.ca          ADSM, AIX Support, RS/6000 SP, HACMP