tests/badserverext.py
changeset 33193 cbb50fd830ea
parent 33192 c538fca0d511
child 33194 c077eac329e2
equal deleted inserted replaced
33192:c538fca0d511 33193:cbb50fd830ea
    46 
    46 
    47 configitem('badserver', 'closeafteraccept',
    47 configitem('badserver', 'closeafteraccept',
    48     default=False,
    48     default=False,
    49 )
    49 )
    50 configitem('badserver', 'closeafterrecvbytes',
    50 configitem('badserver', 'closeafterrecvbytes',
       
    51     default=0,
       
    52 )
       
    53 configitem('badserver', 'closeaftersendbytes',
    51     default=0,
    54     default=0,
    52 )
    55 )
    53 
    56 
    54 # We can't adjust __class__ on a socket instance. So we define a proxy type.
    57 # We can't adjust __class__ on a socket instance. So we define a proxy type.
    55 class socketproxy(object):
    58 class socketproxy(object):
   270         def process_request(self, socket, address):
   273         def process_request(self, socket, address):
   271             # Wrap socket in a proxy if we need to count bytes.
   274             # Wrap socket in a proxy if we need to count bytes.
   272             closeafterrecvbytes = self._ui.configint('badserver',
   275             closeafterrecvbytes = self._ui.configint('badserver',
   273                                                      'closeafterrecvbytes')
   276                                                      'closeafterrecvbytes')
   274             closeaftersendbytes = self._ui.configint('badserver',
   277             closeaftersendbytes = self._ui.configint('badserver',
   275                                                      'closeaftersendbytes', 0)
   278                                                      'closeaftersendbytes')
   276 
   279 
   277             if closeafterrecvbytes or closeaftersendbytes:
   280             if closeafterrecvbytes or closeaftersendbytes:
   278                 socket = socketproxy(socket, self.errorlog,
   281                 socket = socketproxy(socket, self.errorlog,
   279                                      closeafterrecvbytes=closeafterrecvbytes,
   282                                      closeafterrecvbytes=closeafterrecvbytes,
   280                                      closeaftersendbytes=closeaftersendbytes)
   283                                      closeaftersendbytes=closeaftersendbytes)