Mercurial > hg
comparison mercurial/url.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 | f2dffa1359c6 |
children | 6509fcec830c |
comparison
equal
deleted
inserted
replaced
40033:5e5b06087ec5 | 40034:393e44324037 |
---|---|
552 handlers.extend((httpbasicauthhandler(passmgr), | 552 handlers.extend((httpbasicauthhandler(passmgr), |
553 httpdigestauthhandler(passmgr))) | 553 httpdigestauthhandler(passmgr))) |
554 handlers.extend([h(ui, passmgr) for h in handlerfuncs]) | 554 handlers.extend([h(ui, passmgr) for h in handlerfuncs]) |
555 handlers.append(cookiehandler(ui)) | 555 handlers.append(cookiehandler(ui)) |
556 opener = urlreq.buildopener(*handlers) | 556 opener = urlreq.buildopener(*handlers) |
557 | |
558 # keepalive.py's handlers will populate these attributes if they exist. | |
559 opener.requestscount = 0 | |
560 opener.sentbytescount = 0 | |
561 opener.receivedbytescount = 0 | |
557 | 562 |
558 # The user agent should should *NOT* be used by servers for e.g. | 563 # The user agent should should *NOT* be used by servers for e.g. |
559 # protocol detection or feature negotiation: there are other | 564 # protocol detection or feature negotiation: there are other |
560 # facilities for that. | 565 # facilities for that. |
561 # | 566 # |