Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 35986:98a00aa0288d
wireprotoserver: move error response handling out of hgweb
The exception handler for ErrorResponse has more to do with the
wire protocol than the generic HTTP server. Move the code so it
lives alongside other wire protocol code.
Differential Revision: https://phab.mercurial-scm.org/D2021
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 31 Jan 2018 17:34:45 -0800 |
parents | e69e65b2b4a9 |
children | af0a19d8812b |
comparison
equal
deleted
inserted
replaced
35985:e69e65b2b4a9 | 35986:98a00aa0288d |
---|---|
367 if query: | 367 if query: |
368 raise ErrorResponse(HTTP_NOT_FOUND) | 368 raise ErrorResponse(HTTP_NOT_FOUND) |
369 if cmd in perms: | 369 if cmd in perms: |
370 self.check_perm(rctx, req, perms[cmd]) | 370 self.check_perm(rctx, req, perms[cmd]) |
371 except ErrorResponse as inst: | 371 except ErrorResponse as inst: |
372 # A client that sends unbundle without 100-continue will | 372 return protohandler['handleerror'](inst) |
373 # break if we respond early. | |
374 if (cmd == 'unbundle' and | |
375 (req.env.get('HTTP_EXPECT', | |
376 '').lower() != '100-continue') or | |
377 req.env.get('X-HgHttp2', '')): | |
378 req.drain() | |
379 else: | |
380 req.headers.append((r'Connection', r'Close')) | |
381 req.respond(inst, wireprotoserver.HGTYPE, | |
382 body='0\n%s\n' % inst) | |
383 return '' | |
384 | 373 |
385 return protohandler['dispatch']() | 374 return protohandler['dispatch']() |
386 | 375 |
387 # translate user-visible url structure to internal structure | 376 # translate user-visible url structure to internal structure |
388 | 377 |