Wed Dec 21 22:24:47 UTC 2005 gaetan.lehmann@jouy.inra.fr * enhance mime type for binary files diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi --- old-darcsweb/darcsweb.cgi 2015-11-15 00:21:10.000000000 +0000 +++ new-darcsweb/darcsweb.cgi 2015-11-15 00:21:10.000000000 +0000 @@ -20,6 +20,7 @@ import xml.sax from xml.sax.saxutils import escape as xml_escape import email.Utils +import mimetypes iso_datetime = '%Y-%m-%dT%H:%M:%SZ' @@ -396,7 +397,14 @@ print "Content-type: text/plain; charset=utf-8\n" def print_binary_header(fname = None): - print "Content-type: application/octet-stream" + if fname : + (mime, enc) = mimetypes.guess_type(fname) + else : + mime = None + if mime : + print "Content-type: %s" % mime + else : + print "Content-type: application/octet-stream" if fname: print "Content-Disposition:attachment;filename=%s" % fname print