Serving binary data from a cgi-script

Thomas W thomas.weholt at gmail.com
Wed May 11 05:16:27 EDT 2005


Hi,

I'm having some problems serving binary data in a simple CGI-script.
I'm setting content-type ( "application/octet-stream" ), content-length
and Content-disposition and I think these are correct, but the size of
the served file/data is different than the source. The read and write
the data I'm doing a plain :

f = open (..., 'rb')
d = f.read(2048)
while d:
  if not d: break
  print d
  d = f.read(2048)
f.close()

Any hints?

Best regards,
Thomas




More information about the Python-list mailing list