470,580 Members | 2,244 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,580 developers. It's quick & easy.

Serving binary data from a cgi-script


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)

Any hints?

Best regards,

Jul 19 '05 #1
2 2335
Thomas W wrote:
print d


use sys.stdout.write instead, print is adding linebreaks ...

HtH, Roland
Jul 19 '05 #2
Yeah... I once spent ages going round in circles trying to track that
down. A happy way to spend an evening...



Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Margaret MacDonald | last post: by
5 posts views Thread by Blaktyger | last post: by
2 posts views Thread by Erik Johnson | last post: by
11 posts views Thread by Charles T. | last post: by
8 posts views Thread by John Forkosh | last post: by
7 posts views Thread by robert.differentone | last post: by
13 posts views Thread by greg | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.