mercurial/httprepo.py
changeset 3548 88b4755fa48f
parent 3445 233c733e4af5
child 3551 9073d7366776
equal deleted inserted replaced
3547:8c617d48564a 3548:88b4755fa48f
   216         data = args.pop('data', None)
   216         data = args.pop('data', None)
   217         headers = args.pop('headers', {})
   217         headers = args.pop('headers', {})
   218         self.ui.debug(_("sending %s command\n") % cmd)
   218         self.ui.debug(_("sending %s command\n") % cmd)
   219         q = {"cmd": cmd}
   219         q = {"cmd": cmd}
   220         q.update(args)
   220         q.update(args)
   221         qs = urllib.urlencode(q)
   221         qs = '?%s' % urllib.urlencode(q)
   222         cu = "%s?%s" % (self._url, qs)
   222         cu = "%s%s" % (self._url, qs)
   223         try:
   223         try:
   224             resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
   224             resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
   225         except urllib2.HTTPError, inst:
   225         except urllib2.HTTPError, inst:
   226             if inst.code == 401:
   226             if inst.code == 401:
   227                 raise util.Abort(_('authorization failed'))
   227                 raise util.Abort(_('authorization failed'))
   231             self.ui.print_exc()
   231             self.ui.print_exc()
   232             raise IOError(None, inst)
   232             raise IOError(None, inst)
   233         except IndexError:
   233         except IndexError:
   234             # this only happens with Python 2.3, later versions raise URLError
   234             # this only happens with Python 2.3, later versions raise URLError
   235             raise util.Abort(_('http error, possibly caused by proxy setting'))
   235             raise util.Abort(_('http error, possibly caused by proxy setting'))
       
   236         # record the url we got redirected to
       
   237         self._url = resp.geturl().rstrip(qs)
   236         try:
   238         try:
   237             proto = resp.getheader('content-type')
   239             proto = resp.getheader('content-type')
   238         except AttributeError:
   240         except AttributeError:
   239             proto = resp.headers['content-type']
   241             proto = resp.headers['content-type']
   240 
   242