##// END OF EJS Templates
url: support suppressing Accept header...
Gregory Szorc -
r37273:a708e1e4 default
parent child Browse files
Show More
@@ -2846,6 +2846,12 b' def debugwireproto(ui, repo, path=None, '
2846 if ui.debugflag:
2846 if ui.debugflag:
2847 openerargs[r'loggingopts'][r'logdataapis'] = True
2847 openerargs[r'loggingopts'][r'logdataapis'] = True
2848
2848
2849 # Don't send default headers when in raw mode. This allows us to
2850 # bypass most of the behavior of our URL handling code so we can
2851 # have near complete control over what's sent on the wire.
2852 if opts['peer'] == 'raw':
2853 openerargs[r'sendaccept'] = False
2854
2849 opener = urlmod.opener(ui, authinfo, **openerargs)
2855 opener = urlmod.opener(ui, authinfo, **openerargs)
2850
2856
2851 if opts['peer'] == 'raw':
2857 if opts['peer'] == 'raw':
@@ -494,7 +494,7 b' class cookiehandler(urlreq.basehandler):'
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
@@ -506,6 +506,9 b' def opener(ui, authinfo=None, useragent='
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
@@ -562,7 +565,9 b' def opener(ui, authinfo=None, useragent='
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):
@@ -215,15 +215,13 b' Same thing, but with "httprequest" comma'
215
215
216 $ hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT << EOF
216 $ hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT << EOF
217 > httprequest GET ?cmd=listkeys
217 > httprequest GET ?cmd=listkeys
218 > accept: application/mercurial-0.1
218 > user-agent: test
219 > user-agent: mercurial/proto-1.0 (Mercurial 42)
220 > x-hgarg-1: namespace=namespaces
219 > x-hgarg-1: namespace=namespaces
221 > EOF
220 > EOF
222 using raw connection to peer
221 using raw connection to peer
223 s> GET /?cmd=listkeys HTTP/1.1\r\n
222 s> GET /?cmd=listkeys HTTP/1.1\r\n
224 s> Accept-Encoding: identity\r\n
223 s> Accept-Encoding: identity\r\n
225 s> accept: application/mercurial-0.1\r\n
224 s> user-agent: test\r\n
226 s> user-agent: mercurial/proto-1.0 (Mercurial 42)\r\n
227 s> x-hgarg-1: namespace=namespaces\r\n
225 s> x-hgarg-1: namespace=namespaces\r\n
228 s> host: $LOCALIP:$HGPORT\r\n (glob)
226 s> host: $LOCALIP:$HGPORT\r\n (glob)
229 s> \r\n
227 s> \r\n
General Comments 0
You need to be logged in to leave comments. Login now