493 # name and version. Other client implementations should choose their |
494 # name and version. Other client implementations should choose their |
494 # own distribution name. Since servers should not be using the user |
495 # own distribution name. Since servers should not be using the user |
495 # agent string for anything, clients should be able to define whatever |
496 # agent string for anything, clients should be able to define whatever |
496 # user agent they deem appropriate. |
497 # user agent they deem appropriate. |
497 agent = 'mercurial/proto-1.0 (Mercurial %s)' % util.version() |
498 agent = 'mercurial/proto-1.0 (Mercurial %s)' % util.version() |
498 opener.addheaders = [('User-agent', agent)] |
499 opener.addheaders = [(r'User-agent', pycompat.sysstr(agent))] |
499 |
500 |
500 # This header should only be needed by wire protocol requests. But it has |
501 # This header should only be needed by wire protocol requests. But it has |
501 # been sent on all requests since forever. We keep sending it for backwards |
502 # been sent on all requests since forever. We keep sending it for backwards |
502 # compatibility reasons. Modern versions of the wire protocol use |
503 # compatibility reasons. Modern versions of the wire protocol use |
503 # X-HgProto-<N> for advertising client support. |
504 # X-HgProto-<N> for advertising client support. |
504 opener.addheaders.append(('Accept', 'application/mercurial-0.1')) |
505 opener.addheaders.append((r'Accept', r'application/mercurial-0.1')) |
505 return opener |
506 return opener |
506 |
507 |
507 def open(ui, url_, data=None): |
508 def open(ui, url_, data=None): |
508 u = util.url(url_) |
509 u = util.url(url_) |
509 if u.scheme: |
510 if u.scheme: |