ayé. J'ai trouvé.
Sous tous les Unix, stdout est ouvert en mode binaire.
Mais pas sous Windows.
Il faut donc forcer stdout en mode binaire.
Le CGI devient:
import sys
import cgitb; cgitb.enable()
if sys.platform == "win32":
import os, msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
sys.stdout.write('Content-Type: application/octet-stream\r\n')
sys.stdout.write('\r\n')
data = open('toto.zip','rb').read()
sys.stdout.write(data)
Et ça marche !
Ouf.
(Référence: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65443 )


