491 # We are allowed to access read-only commands under the rw URL. |
491 # We are allowed to access read-only commands under the rw URL. |
492 assert wirecommand.permission in ('push', 'pull') |
492 assert wirecommand.permission in ('push', 'pull') |
493 |
493 |
494 rsp = wireproto.dispatch(repo, proto, command['command']) |
494 rsp = wireproto.dispatch(repo, proto, command['command']) |
495 |
495 |
496 # TODO use proper response format. |
|
497 res.status = b'200 OK' |
496 res.status = b'200 OK' |
498 res.headers[b'Content-Type'] = b'text/plain' |
497 res.headers[b'Content-Type'] = FRAMINGTYPE |
499 |
498 |
500 if isinstance(rsp, wireprototypes.bytesresponse): |
499 if isinstance(rsp, wireprototypes.bytesresponse): |
501 res.setbodybytes(rsp.data) |
500 action, meta = reactor.onbytesresponseready(rsp.data) |
502 else: |
501 else: |
503 res.setbodybytes(b'unhandled response type from wire proto ' |
502 action, meta = reactor.onapplicationerror( |
504 'command') |
503 _('unhandled response type from wire proto command')) |
|
504 |
|
505 if action == 'sendframes': |
|
506 res.setbodygen(meta['framegen']) |
|
507 else: |
|
508 raise error.ProgrammingError('unhandled event from reactor: %s' % |
|
509 action) |
505 |
510 |
506 # Maps API name to metadata so custom API can be registered. |
511 # Maps API name to metadata so custom API can be registered. |
507 API_HANDLERS = { |
512 API_HANDLERS = { |
508 HTTPV2: { |
513 HTTPV2: { |
509 'config': ('experimental', 'web.api.http-v2'), |
514 'config': ('experimental', 'web.api.http-v2'), |