changeset 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 8c617d48564a
children db946221a58a
files mercurial/httprepo.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httprepo.py	Fri Oct 27 10:24:19 2006 +0200
+++ b/mercurial/httprepo.py	Fri Oct 27 15:02:27 2006 +0200
@@ -218,8 +218,8 @@
         self.ui.debug(_("sending %s command\n") % cmd)
         q = {"cmd": cmd}
         q.update(args)
-        qs = urllib.urlencode(q)
-        cu = "%s?%s" % (self._url, qs)
+        qs = '?%s' % urllib.urlencode(q)
+        cu = "%s%s" % (self._url, qs)
         try:
             resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
         except urllib2.HTTPError, inst:
@@ -233,6 +233,8 @@
         except IndexError:
             # this only happens with Python 2.3, later versions raise URLError
             raise util.Abort(_('http error, possibly caused by proxy setting'))
+        # record the url we got redirected to
+        self._url = resp.geturl().rstrip(qs)
         try:
             proto = resp.getheader('content-type')
         except AttributeError: