Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 37558:8a73132214a3
httppeer: support protocol upgrade
With the new handshake defined and in place on the server, we can
now implement it on the client.
The HTTP handshake mechanism has been taught to add headers advertising
its support for the new capabilities response. Response handling
has been adjusted to allow CBOR responses through. And makepeer()
has been taught to instantiate a mutually supported peer.
The HTTPv2 peer class doesn't implement the full peer interface. So
HTTPv2 is not yet usable as a peer.
Like the server side, we support registering handlers for
different API services. This allows extensions to easily implement
API services and peers. A practical use case for this is to
provide a previous implementation of the experimental version 2
wire protocol to a future version of Mercurial. We know there will
be BC breaks after 4.6 ships. But someone could take the peer and
server code from 4.6, drop it in an extension, and allow its use
indefinitely.
Differential Revision: https://phab.mercurial-scm.org/D3243
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 10 Apr 2018 18:16:47 -0700 |
parents | 734515aca84d |
children | 77c9ee77687c |
comparison
equal
deleted
inserted
replaced
37557:734515aca84d | 37558:8a73132214a3 |
---|---|
81 url as urlmod, | 81 url as urlmod, |
82 util, | 82 util, |
83 vfs as vfsmod, | 83 vfs as vfsmod, |
84 wireprotoframing, | 84 wireprotoframing, |
85 wireprotoserver, | 85 wireprotoserver, |
86 wireprototypes, | |
86 ) | 87 ) |
87 from .utils import ( | 88 from .utils import ( |
88 dateutil, | 89 dateutil, |
89 procutil, | 90 procutil, |
90 stringutil, | 91 stringutil, |
2908 | 2909 |
2909 opener = urlmod.opener(ui, authinfo, **openerargs) | 2910 opener = urlmod.opener(ui, authinfo, **openerargs) |
2910 | 2911 |
2911 if opts['peer'] == 'http2': | 2912 if opts['peer'] == 'http2': |
2912 ui.write(_('creating http peer for wire protocol version 2\n')) | 2913 ui.write(_('creating http peer for wire protocol version 2\n')) |
2913 peer = httppeer.httpv2peer(ui, path, opener) | 2914 peer = httppeer.httpv2peer( |
2915 ui, path, 'api/%s' % wireprototypes.HTTPV2, | |
2916 opener, httppeer.urlreq.request, {}) | |
2914 elif opts['peer'] == 'raw': | 2917 elif opts['peer'] == 'raw': |
2915 ui.write(_('using raw connection to peer\n')) | 2918 ui.write(_('using raw connection to peer\n')) |
2916 peer = None | 2919 peer = None |
2917 elif opts['peer']: | 2920 elif opts['peer']: |
2918 raise error.Abort(_('--peer %s not supported with HTTP peers') % | 2921 raise error.Abort(_('--peer %s not supported with HTTP peers') % |