[Tutor] download dialog-box

Magnus Lycka magnus@thinkware.se
Tue, 01 Oct 2002 23:41:45 +0200


At 17:19 2002-10-01 +0100, alan.gauld@bt.com wrote:
>So what's the problem? Create an HTML file with links
>to the downloadable files.

But maybe he want's to feed the binary directly
from the script?

Then it's basically a matter of supplying the right
headers in the beginning, right? I'm not a big
expert in this...

Maybe there is something more easy to read than
http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc2068.html ?

http://www.cs.tut.fi/~jkorpela/http.html ?

Either way, it's not very Python specific.

I think you should send something like:

content-type:application/octet-stream\r\n
content-lenght:44\r\n
\r\n
binarybinarybinarydlkj=F6sdlkfjs=F6dfkg=F6sdg=F6dsfl

Am I right?

On other words:

###
binary =3D open(filename, 'rb').read()
l =3D len(binary)
type =3D 'application/octet-stream'

fmt =3D "content-type:%s\r\ncontentlenght:%i\r\n\r\n%s"

sys.stdout.write(fmt % (type, l, binary)
###

Anything missing?


--=20
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se