[Zope] ZServer stepping on Content-Type and Content-Length?

Jeff Hoffman jeff.hoffman@goingv.com
Sun, 27 Aug 2000 17:30:01 -0400 (EDT)


Hello,

I am playing around with the new ExtFile product released a few days ago,
in addition to a similar product I wrote myself. Both are exhibiting an
unusual behavior. In the index_html method, I have:

  RESPONSE.setHeader('Content-Type', 'video/foo')
  RESPONSE.setHeader('Content-Length', 1212)

Then, I return the file data. If I launch python and do:

  import Zope, ZPublisher
  ZPublisher.Zope('/path/to/myfile.mpg', d=1)

I can trace the execution of these lines. The headers are set correctly in
the response and, as far as I can tell, are returned correctly in the last
statement my trace executed ("return response").

However, when I telnet to my web port and do:

  HEAD /path/to/myfile.mpg HTTP/1.0

I get:

  Content-Type: video/mpeg
  Content-Length: 0

Remember, I set content-type to video/foo, and length to 1212. These have
been stepped on, I believe, by ZServer. I found this section in 
ZServer/medusa/default_handler.py:

  request['Last-Modified'] = http_date.build_http_date (mtime)
  request['Content-Length'] = file_length
  self.set_content_type (path, request)

While I don't know, for sure, that this is what's causing my problem, it
looks suspect to me.

The curious thing is, using Zope's File object (defined in
lib/python/OFS/Image.py), I get the correct Content-Length coming back. I
did not check to see if Content-Type was overwritten or not. As far as I
can tell, there is no difference in the way my code returns the file data
versus the way Zope's File object does.

Anyone know what's going on?

--Jeff

---
Jeff K. Hoffman                               704.849.0731 x108
Chief Technology Officer                      mailto:jeff.hoffman@goingv.com
Going Virtual, L.L.C.                         http://www.goingv.com/