Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/common.py @ 36879:98baf8dea553
hgweb: port static file handling to new response API
hgwebdir_mod hasn't received as much porting effort. So we had to
do some minor plumbing to get it to match hgweb_mod and to support
the new response object.
Differential Revision: https://phab.mercurial-scm.org/D2789
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 10 Mar 2018 15:46:29 -0800 |
parents | 7ad6a275316f |
children | 02bea04b4c54 |
line wrap: on
line diff
--- a/mercurial/hgweb/common.py Sat Mar 10 15:37:29 2018 -0800 +++ b/mercurial/hgweb/common.py Sat Mar 10 15:46:29 2018 -0800 @@ -153,7 +153,7 @@ return True -def staticfile(directory, fname, req): +def staticfile(directory, fname, res): """return a file inside directory with guessed Content-Type header fname always uses '/' as directory separator and isn't allowed to @@ -178,7 +178,9 @@ with open(path, 'rb') as fh: data = fh.read() - req.respond(HTTP_OK, ct, body=data) + res.headers['Content-Type'] = ct + res.setbodybytes(data) + return res except TypeError: raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename') except OSError as err: