equal
deleted
inserted
replaced
492 return request |
492 return request |
493 |
493 |
494 handlerfuncs = [] |
494 handlerfuncs = [] |
495 |
495 |
496 def opener(ui, authinfo=None, useragent=None, loggingfh=None, |
496 def opener(ui, authinfo=None, useragent=None, loggingfh=None, |
497 loggingname=b's', loggingopts=None): |
497 loggingname=b's', loggingopts=None, sendaccept=True): |
498 ''' |
498 ''' |
499 construct an opener suitable for urllib2 |
499 construct an opener suitable for urllib2 |
500 authinfo will be added to the password manager |
500 authinfo will be added to the password manager |
501 |
501 |
502 The opener can be configured to log socket events if the various |
502 The opener can be configured to log socket events if the various |
504 |
504 |
505 ``loggingfh`` denotes a file object to log events to. |
505 ``loggingfh`` denotes a file object to log events to. |
506 ``loggingname`` denotes the name of the to print when logging. |
506 ``loggingname`` denotes the name of the to print when logging. |
507 ``loggingopts`` is a dict of keyword arguments to pass to the constructed |
507 ``loggingopts`` is a dict of keyword arguments to pass to the constructed |
508 ``util.socketobserver`` instance. |
508 ``util.socketobserver`` instance. |
|
509 |
|
510 ``sendaccept`` allows controlling whether the ``Accept`` request header |
|
511 is sent. The header is sent by default. |
509 ''' |
512 ''' |
510 handlers = [] |
513 handlers = [] |
511 |
514 |
512 if loggingfh: |
515 if loggingfh: |
513 handlers.append(logginghttphandler(loggingfh, loggingname, |
516 handlers.append(logginghttphandler(loggingfh, loggingname, |
560 |
563 |
561 # This header should only be needed by wire protocol requests. But it has |
564 # This header should only be needed by wire protocol requests. But it has |
562 # been sent on all requests since forever. We keep sending it for backwards |
565 # been sent on all requests since forever. We keep sending it for backwards |
563 # compatibility reasons. Modern versions of the wire protocol use |
566 # compatibility reasons. Modern versions of the wire protocol use |
564 # X-HgProto-<N> for advertising client support. |
567 # X-HgProto-<N> for advertising client support. |
565 opener.addheaders.append((r'Accept', r'application/mercurial-0.1')) |
568 if sendaccept: |
|
569 opener.addheaders.append((r'Accept', r'application/mercurial-0.1')) |
|
570 |
566 return opener |
571 return opener |
567 |
572 |
568 def open(ui, url_, data=None): |
573 def open(ui, url_, data=None): |
569 u = util.url(url_) |
574 u = util.url(url_) |
570 if u.scheme: |
575 if u.scheme: |