Show More
@@ -2915,7 +2915,8 b' def debugwireproto(ui, repo, path=None, ' | |||||
2915 | raise error.Abort(_('--peer %s not supported with HTTP peers') % |
|
2915 | raise error.Abort(_('--peer %s not supported with HTTP peers') % | |
2916 | opts['peer']) |
|
2916 | opts['peer']) | |
2917 | else: |
|
2917 | else: | |
2918 |
peer = httppeer.httppeer(ui, path, url, opener |
|
2918 | peer = httppeer.httppeer(ui, path, url, opener, | |
|
2919 | requestbuilder=httppeer.urlreq.request) | |||
2919 | peer._fetchcaps() |
|
2920 | peer._fetchcaps() | |
2920 |
|
2921 | |||
2921 | # We /could/ populate stdin/stdout with sock.makefile()... |
|
2922 | # We /could/ populate stdin/stdout with sock.makefile()... |
@@ -139,15 +139,13 b' class _multifile(object):' | |||||
139 | self._index = 0 |
|
139 | self._index = 0 | |
140 |
|
140 | |||
141 | class httppeer(wireproto.wirepeer): |
|
141 | class httppeer(wireproto.wirepeer): | |
142 | def __init__(self, ui, path, url, opener): |
|
142 | def __init__(self, ui, path, url, opener, requestbuilder): | |
143 | self.ui = ui |
|
143 | self.ui = ui | |
144 | self._path = path |
|
144 | self._path = path | |
145 | self._url = url |
|
145 | self._url = url | |
146 | self._caps = None |
|
146 | self._caps = None | |
147 | self._urlopener = opener |
|
147 | self._urlopener = opener | |
148 | # This is an its own attribute to facilitate extensions overriding |
|
148 | self._requestbuilder = requestbuilder | |
149 | # the default type. |
|
|||
150 | self._requestbuilder = urlreq.request |
|
|||
151 |
|
149 | |||
152 | def __del__(self): |
|
150 | def __del__(self): | |
153 | for h in self._urlopener.handlers: |
|
151 | for h in self._urlopener.handlers: | |
@@ -570,7 +568,12 b' class httpv2peer(object):' | |||||
570 |
|
568 | |||
571 | return results |
|
569 | return results | |
572 |
|
570 | |||
573 | def makepeer(ui, path): |
|
571 | def makepeer(ui, path, requestbuilder=urlreq.request): | |
|
572 | """Construct an appropriate HTTP peer instance. | |||
|
573 | ||||
|
574 | ``requestbuilder`` is the type used for constructing HTTP requests. | |||
|
575 | It exists as an argument so extensions can override the default. | |||
|
576 | """ | |||
574 | u = util.url(path) |
|
577 | u = util.url(path) | |
575 | if u.query or u.fragment: |
|
578 | if u.query or u.fragment: | |
576 | raise error.Abort(_('unsupported URL component: "%s"') % |
|
579 | raise error.Abort(_('unsupported URL component: "%s"') % | |
@@ -582,7 +585,7 b' def makepeer(ui, path):' | |||||
582 |
|
585 | |||
583 | opener = urlmod.opener(ui, authinfo) |
|
586 | opener = urlmod.opener(ui, authinfo) | |
584 |
|
587 | |||
585 | return httppeer(ui, path, url, opener) |
|
588 | return httppeer(ui, path, url, opener, requestbuilder) | |
586 |
|
589 | |||
587 | def instance(ui, path, create): |
|
590 | def instance(ui, path, create): | |
588 | if create: |
|
591 | if create: |
@@ -70,7 +70,7 b' class dummyopener(object):' | |||||
70 | # Facilitates testing sshpeer without requiring an SSH server. |
|
70 | # Facilitates testing sshpeer without requiring an SSH server. | |
71 | class badpeer(httppeer.httppeer): |
|
71 | class badpeer(httppeer.httppeer): | |
72 | def __init__(self): |
|
72 | def __init__(self): | |
73 | super(badpeer, self).__init__(None, None, None, dummyopener()) |
|
73 | super(badpeer, self).__init__(None, None, None, dummyopener(), None) | |
74 | self.badattribute = True |
|
74 | self.badattribute = True | |
75 |
|
75 | |||
76 | def badmethod(self): |
|
76 | def badmethod(self): | |
@@ -89,7 +89,7 b' def main():' | |||||
89 |
|
89 | |||
90 | ziverify.verifyClass(repository.ipeerbaselegacycommands, |
|
90 | ziverify.verifyClass(repository.ipeerbaselegacycommands, | |
91 | httppeer.httppeer) |
|
91 | httppeer.httppeer) | |
92 | checkzobject(httppeer.httppeer(None, None, None, dummyopener())) |
|
92 | checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None)) | |
93 |
|
93 | |||
94 | ziverify.verifyClass(repository.ipeerbase, |
|
94 | ziverify.verifyClass(repository.ipeerbase, | |
95 | localrepo.localpeer) |
|
95 | localrepo.localpeer) |
General Comments 0
You need to be logged in to leave comments.
Login now