Mercurial > public > mercurial-scm > hg
comparison mercurial/httprepo.py @ 3562:88b4755fa48f
httprepo: record the url after a request, makes pull + redirect works
POST+redirect doesn't work in python, as a workaround we record the url
from the previous GETs so that when we do a POST it uses the redirected url
fix issue327
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 27 Oct 2006 15:02:27 +0200 |
parents | 233c733e4af5 |
children | 9073d7366776 |
comparison
equal
deleted
inserted
replaced
3561:8c617d48564a | 3562: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 |