comparison mercurial/httppeer.py @ 40034:393e44324037

httppeer: report http statistics Now that keepalive.py records HTTP request count and the number of bytes sent and received as part of performing those requests, we can easily print a report on the activity when closing a peer instance! Exact byte counts are globbed in tests because they are influenced by non-deterministic things, such as hostnames and port numbers. Plus, the exact byte count isn't too important anyway. I feel obliged to note that printing the byte count could have security implications. e.g. if sending a password via HTTP basic auth, the length of that password will influence the byte count and the reporting of the byte count could be a side-channel leak of the password length. I /think/ this is beyond our threshold for concern. But if we think it poses a problem, we can teach the byte count logging code to e.g. ignore sensitive HTTP request headers. We could also consider not reporting the byte count of request headers altogether. But since the wire protocol uses HTTP headers for sending command arguments, it is kind of important to report their size. Differential Revision: https://phab.mercurial-scm.org/D4858
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 01 Oct 2018 13:17:38 -0700
parents 7e807b8a9e56
children 293835e0fff7
comparison
equal deleted inserted replaced
40033:5e5b06087ec5 40034:393e44324037
403 403
404 def canpush(self): 404 def canpush(self):
405 return True 405 return True
406 406
407 def close(self): 407 def close(self):
408 pass 408 self.ui.note(_('(sent %d HTTP requests and %d bytes; '
409 'received %d bytes in responses)\n') %
410 (self._urlopener.requestscount,
411 self._urlopener.sentbytescount,
412 self._urlopener.receivedbytescount))
409 413
410 # End of ipeerconnection interface. 414 # End of ipeerconnection interface.
411 415
412 # Begin of ipeercommands interface. 416 # Begin of ipeercommands interface.
413 417
756 def canpush(self): 760 def canpush(self):
757 # TODO change once implemented. 761 # TODO change once implemented.
758 return False 762 return False
759 763
760 def close(self): 764 def close(self):
761 pass 765 self.ui.note(_('(sent %d HTTP requests and %d bytes; '
766 'received %d bytes in responses)\n') %
767 (self._opener.requestscount,
768 self._opener.sentbytescount,
769 self._opener.receivedbytescount))
762 770
763 # End of ipeerconnection. 771 # End of ipeerconnection.
764 772
765 # Start of ipeercapabilities. 773 # Start of ipeercapabilities.
766 774