comparison mercurial/hgweb/hgweb_mod.py @ 36877:9fc3d814646e

hgweb: port most @webcommand to use modern response type This only focused on porting the return value. raw file requests are wonky because they go through a separate code path at the dispatch layer. Now that everyone is using the same API, we could clean this up. It's worth noting that wsgirequest.respond() allows sending the Content-Disposition header, but the only user of that feature was removed as part of this change (with the setting of the header now being performed inline). A few @webcommand are not as straightforward as the others and they have not been ported yet. Differential Revision: https://phab.mercurial-scm.org/D2787
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 20:36:34 -0800
parents 1f42d621f090
children 89002d07a114
comparison
equal deleted inserted replaced
36876:1f42d621f090 36877:9fc3d814646e
398 398
399 if cmd not in webcommands.__all__: 399 if cmd not in webcommands.__all__:
400 msg = 'no such method: %s' % cmd 400 msg = 'no such method: %s' % cmd
401 raise ErrorResponse(HTTP_BAD_REQUEST, msg) 401 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
402 elif cmd == 'file' and req.qsparams.get('style') == 'raw': 402 elif cmd == 'file' and req.qsparams.get('style') == 'raw':
403 rctx.ctype = ctype 403 res.status = '200 Script output follows'
404 res.headers['Content-Type'] = ctype
404 content = webcommands.rawfile(rctx, wsgireq, tmpl) 405 content = webcommands.rawfile(rctx, wsgireq, tmpl)
406 assert content is res
407 return res.sendresponse()
405 else: 408 else:
406 # Set some globals appropriate for web handlers. Commands can 409 # Set some globals appropriate for web handlers. Commands can
407 # override easily enough. 410 # override easily enough.
408 res.status = '200 Script output follows' 411 res.status = '200 Script output follows'
409 res.headers['Content-Type'] = ctype 412 res.headers['Content-Type'] = ctype