510 # The "(Mercurial %s)" string contains the distribution |
510 # The "(Mercurial %s)" string contains the distribution |
511 # name and version. Other client implementations should choose their |
511 # name and version. Other client implementations should choose their |
512 # own distribution name. Since servers should not be using the user |
512 # own distribution name. Since servers should not be using the user |
513 # agent string for anything, clients should be able to define whatever |
513 # agent string for anything, clients should be able to define whatever |
514 # user agent they deem appropriate. |
514 # user agent they deem appropriate. |
515 agent = 'mercurial/proto-1.0 (Mercurial %s)' % util.version() |
515 # |
516 opener.addheaders = [(r'User-agent', pycompat.sysstr(agent))] |
516 # The custom user agent is for lfs, because unfortunately some servers |
|
517 # do look at this value. |
|
518 if not useragent: |
|
519 agent = 'mercurial/proto-1.0 (Mercurial %s)' % util.version() |
|
520 opener.addheaders = [(r'User-agent', pycompat.sysstr(agent))] |
|
521 else: |
|
522 opener.addheaders = [(r'User-agent', pycompat.sysstr(useragent))] |
517 |
523 |
518 # This header should only be needed by wire protocol requests. But it has |
524 # This header should only be needed by wire protocol requests. But it has |
519 # been sent on all requests since forever. We keep sending it for backwards |
525 # been sent on all requests since forever. We keep sending it for backwards |
520 # compatibility reasons. Modern versions of the wire protocol use |
526 # compatibility reasons. Modern versions of the wire protocol use |
521 # X-HgProto-<N> for advertising client support. |
527 # X-HgProto-<N> for advertising client support. |