360 # process this if it's a protocol request |
360 # process this if it's a protocol request |
361 # protocol bits don't need to create any URLs |
361 # protocol bits don't need to create any URLs |
362 # and the clients always use the old URL structure |
362 # and the clients always use the old URL structure |
363 |
363 |
364 cmd = pycompat.sysbytes(req.form.get(r'cmd', [r''])[0]) |
364 cmd = pycompat.sysbytes(req.form.get(r'cmd', [r''])[0]) |
365 if protocol.iscmd(cmd): |
365 if wireprotoserver.iscmd(cmd): |
366 try: |
366 try: |
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 return protocol.call(rctx.repo, req, cmd) |
371 return wireprotoserver.call(rctx.repo, req, cmd) |
372 except ErrorResponse as inst: |
372 except ErrorResponse as inst: |
373 # A client that sends unbundle without 100-continue will |
373 # A client that sends unbundle without 100-continue will |
374 # break if we respond early. |
374 # break if we respond early. |
375 if (cmd == 'unbundle' and |
375 if (cmd == 'unbundle' and |
376 (req.env.get('HTTP_EXPECT', |
376 (req.env.get('HTTP_EXPECT', |
377 '').lower() != '100-continue') or |
377 '').lower() != '100-continue') or |
378 req.env.get('X-HgHttp2', '')): |
378 req.env.get('X-HgHttp2', '')): |
379 req.drain() |
379 req.drain() |
380 else: |
380 else: |
381 req.headers.append((r'Connection', r'Close')) |
381 req.headers.append((r'Connection', r'Close')) |
382 req.respond(inst, protocol.HGTYPE, |
382 req.respond(inst, wireprotoserver.HGTYPE, |
383 body='0\n%s\n' % inst) |
383 body='0\n%s\n' % inst) |
384 return '' |
384 return '' |
385 |
385 |
386 # translate user-visible url structure to internal structure |
386 # translate user-visible url structure to internal structure |
387 |
387 |