comparison mercurial/hgweb/webcommands.py @ 6981:029a54423a96

hgweb: Serve raw non-binary files as text/plain Previously these were served as application/octet-stream usually making browsers download them as files though they can be displayed inline just fine. This is useful to refer to e.g. /project/raw-file/tip/README.
author Rocco Rutte <pdmef@gmx.net>
date Wed, 03 Sep 2008 15:46:46 +0200
parents e8c2dae47799
children b84d27386285
comparison
equal deleted inserted replaced
6980:2268edff1bec 6981:029a54423a96
48 raise inst 48 raise inst
49 49
50 path = fctx.path() 50 path = fctx.path()
51 text = fctx.data() 51 text = fctx.data()
52 mt = mimetypes.guess_type(path)[0] 52 mt = mimetypes.guess_type(path)[0]
53 if mt is None or binary(text): 53 if mt is None:
54 mt = mt or 'application/octet-stream' 54 mt = binary(text) and 'application/octet-stream' or 'text/plain'
55 55
56 req.respond(HTTP_OK, mt, path, len(text)) 56 req.respond(HTTP_OK, mt, path, len(text))
57 return [text] 57 return [text]
58 58
59 def _filerevision(web, tmpl, fctx): 59 def _filerevision(web, tmpl, fctx):