[mod_python] Large req.writes prevent header from being outputted?

Mike Bell mike at mikebell.org
Mon Jan 22 16:16:41 EST 2001


With my installation (mod_python 2.7.1 w/python 2.0), doing

  req.content_type = DetermineMimeType(filepath)
  req.send_http_header()
  myjpeg = open(filepath)
  req.write(myjpeg.read())

with a very large image (appears to be around 1/4MB) will result in an HTTP
transaction where no headers are outputted, just binary data. However,
something like

  req.content_type = DetermineMimeType(filepath)
  req.send_http_header()
  myjpeg = open(filepath)
  while 1:
    temp = myjpeg.read(65535)
    if temp == "":
      break
    req.write(temp)

will work just fine.

Presumably req.write should work for these large values, or at least raise
an exception rather than dropping data.



More information about the Mod_python mailing list