44 configtable = {} |
44 configtable = {} |
45 configitem = registrar.configitem(configtable) |
45 configitem = registrar.configitem(configtable) |
46 |
46 |
47 configitem('badserver', 'closeafteraccept', |
47 configitem('badserver', 'closeafteraccept', |
48 default=False, |
48 default=False, |
|
49 ) |
|
50 configitem('badserver', 'closeafterrecvbytes', |
|
51 default=0, |
49 ) |
52 ) |
50 |
53 |
51 # We can't adjust __class__ on a socket instance. So we define a proxy type. |
54 # We can't adjust __class__ on a socket instance. So we define a proxy type. |
52 class socketproxy(object): |
55 class socketproxy(object): |
53 __slots__ = ( |
56 __slots__ = ( |
265 # self.finish_request() which calls self.RequestHandlerClass() which |
268 # self.finish_request() which calls self.RequestHandlerClass() which |
266 # is a hgweb.server._httprequesthandler. |
269 # is a hgweb.server._httprequesthandler. |
267 def process_request(self, socket, address): |
270 def process_request(self, socket, address): |
268 # Wrap socket in a proxy if we need to count bytes. |
271 # Wrap socket in a proxy if we need to count bytes. |
269 closeafterrecvbytes = self._ui.configint('badserver', |
272 closeafterrecvbytes = self._ui.configint('badserver', |
270 'closeafterrecvbytes', 0) |
273 'closeafterrecvbytes') |
271 closeaftersendbytes = self._ui.configint('badserver', |
274 closeaftersendbytes = self._ui.configint('badserver', |
272 'closeaftersendbytes', 0) |
275 'closeaftersendbytes', 0) |
273 |
276 |
274 if closeafterrecvbytes or closeaftersendbytes: |
277 if closeafterrecvbytes or closeaftersendbytes: |
275 socket = socketproxy(socket, self.errorlog, |
278 socket = socketproxy(socket, self.errorlog, |