diff tests/badserverext.py @ 37498:aacfca6f9767

wireproto: support for pullbundles Pullbundles are similar to clonebundles, but served as normal inline bundle streams. They are almost transparent to the client -- the only visible effect is that the client might get less changes than what it asked for, i.e. not all requested head revisions are provided. The client announces support for the necessary retries with the partial-pull capability. After receiving a partial bundle, it updates the set of revisions shared with the server and drops all now-known heads from the request list. It will then rerun getbundle until no changes are received or all remote heads are present. Extend badserverext to support per-socket limit, i.e. don't assume that the same limits should be applied to all sockets. Differential Revision: https://phab.mercurial-scm.org/D1856
author Joerg Sonnenberger <joerg@bec.de>
date Thu, 18 Jan 2018 12:54:01 +0100
parents fb7897e53d49
children cbfab495dbcf
line wrap: on
line diff
--- a/tests/badserverext.py	Fri Apr 06 22:39:58 2018 -0700
+++ b/tests/badserverext.py	Thu Jan 18 12:54:01 2018 +0100
@@ -48,10 +48,10 @@
     default=False,
 )
 configitem(b'badserver', b'closeafterrecvbytes',
-    default=0,
+    default='0',
 )
 configitem(b'badserver', b'closeaftersendbytes',
-    default=0,
+    default='0',
 )
 configitem(b'badserver', b'closebeforeaccept',
     default=False,
@@ -238,6 +238,13 @@
             self._ui = ui
             super(badserver, self).__init__(ui, *args, **kwargs)
 
+            recvbytes = self._ui.config('badserver', 'closeafterrecvbytes')
+            recvbytes = recvbytes.split(',')
+            self.closeafterrecvbytes = [int(v) for v in recvbytes if v]
+            sendbytes = self._ui.config('badserver', 'closeaftersendbytes')
+            sendbytes = sendbytes.split(',')
+            self.closeaftersendbytes = [int(v) for v in sendbytes if v]
+
             # Need to inherit object so super() works.
             class badrequesthandler(self.RequestHandlerClass, object):
                 def send_header(self, name, value):
@@ -275,10 +282,14 @@
         # is a hgweb.server._httprequesthandler.
         def process_request(self, socket, address):
             # Wrap socket in a proxy if we need to count bytes.
-            closeafterrecvbytes = self._ui.configint('badserver',
-                                                     'closeafterrecvbytes')
-            closeaftersendbytes = self._ui.configint('badserver',
-                                                     'closeaftersendbytes')
+            if self.closeafterrecvbytes:
+                closeafterrecvbytes = self.closeafterrecvbytes.pop(0)
+            else:
+                closeafterrecvbytes = 0
+            if self.closeaftersendbytes:
+                closeaftersendbytes = self.closeaftersendbytes.pop(0)
+            else:
+                closeaftersendbytes = 0
 
             if closeafterrecvbytes or closeaftersendbytes:
                 socket = socketproxy(socket, self.errorlog,