comparison mercurial/httprepo.py @ 3553:3bab1fc0ab75

Turn bundle file into a string for http push, for urllib2 over proxies.
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 27 Oct 2006 19:24:57 +0200
parents ca24144ed850
children a27d90c9336e
comparison
equal deleted inserted replaced
3552:ca24144ed850 3553:3bab1fc0ab75
219 q = {"cmd": cmd} 219 q = {"cmd": cmd}
220 q.update(args) 220 q.update(args)
221 qs = '?%s' % 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 if data:
225 if isinstance(data, file):
226 # urllib2 needs string or buffer when using a proxy
227 data.seek(0)
228 data = data.read()
229 self.ui.debug(_("sending %d bytes\n") % len(data))
224 resp = urllib2.urlopen(urllib2.Request(cu, data, headers)) 230 resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
225 except urllib2.HTTPError, inst: 231 except urllib2.HTTPError, inst:
226 if inst.code == 401: 232 if inst.code == 401:
227 raise util.Abort(_('authorization failed')) 233 raise util.Abort(_('authorization failed'))
228 raise 234 raise