[Zope] [BUG] [Zserver] GET and HEAD give different MIME types

Martijn Pieters mj@digicool.com
Wed, 29 Nov 2000 16:22:39 +0100


On Wed, Nov 29, 2000 at 12:06:23PM +0100, Stephane Bortzmeyer wrote:
> On Tuesday 28 November 2000, at 21 h 18, the keyboard of Martijn Pieters 
> <mj@digicool.com> wrote:
> 
> > Note that you don't want the DTML code to be called on a HEAD request; it
> > may have side effects a mere tpc_abort won't roll back.
> 
> I understand but this seems a deviation (I don't say a violation since the RFC 
> says SHOULD and not MUST) from the RFC on HTTP (2616):
> 
> 9.4 HEAD
> 
>    The HEAD method is identical to GET except that the server MUST NOT
>    return a message-body in the response. The metainformation contained
>    in the HTTP headers in response to a HEAD request SHOULD be identical
>    to the information sent in response to a GET request.
> 
> It is certainly a big problem for debugging or for robots which assume they 
> can test with HEAD.

The SHOULD in that text is there _because_ not all web environments can
reliably generate a HEAD response without invoking undesired side-effects.
It is easy with a static website, where there won't be any side effects to
only sending the headers going with a URL, but with a dynamic web server
this is quite different.

If this is really a big problem for you I suggest you upgrade to Zope
2.2.0 or higher. Quite some trouble is taken to ensure that a more
meaningful content-type is returned:

- If the published object has a 'content_type' attribute, it's value will
  be used first. 

- If absent, the ID of the object will be used to guess it's content type.
  Only object names which use extensions benefit (for example: logo.gif
  is probably 'image/gif').

- If no guess could be made, the property 'default_content_type' is used.
  DTML Documents and Methods define this as 'text/html'.

- Only when all three steps above fail will the content type
  'application/octet-stream' be used.

I believe that only the 3rd step was added in 2.2.0b1, so you could try
and add a 'content_type' property to DTML objects that *must* return a
correct content-type.

-- 
Martijn Pieters
| Software Engineer  mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------