comparison mercurial/httprepo.py @ 4232:0d51eb296fb9

Merge with crew-stable
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 16 Mar 2007 00:45:18 -0300
parents 9dc64c8414ca fffacca46f09
children bf8319ee3428
comparison
equal deleted inserted replaced
4224:2a8b6d78d7ee 4232:0d51eb296fb9
72 userpass = urllib.quote(user) + ':' + urllib.quote(passwd) 72 userpass = urllib.quote(user) + ':' + urllib.quote(passwd)
73 else: 73 else:
74 userpass = urllib.quote(user) 74 userpass = urllib.quote(user)
75 return userpass + '@' + hostport 75 return userpass + '@' + hostport
76 return hostport 76 return hostport
77
78 # work around a bug in Python < 2.4.2
79 # (it leaves a "\n" at the end of Proxy-authorization headers)
80 class request(urllib2.Request):
81 def add_header(self, key, val):
82 if key.lower() == 'proxy-authorization':
83 val = val.strip()
84 return urllib2.Request.add_header(self, key, val)
77 85
78 class httpsendfile(file): 86 class httpsendfile(file):
79 def __len__(self): 87 def __len__(self):
80 return os.fstat(self.fileno()).st_size 88 return os.fstat(self.fileno()).st_size
81 89
236 cu = "%s%s" % (self._url, qs) 244 cu = "%s%s" % (self._url, qs)
237 try: 245 try:
238 if data: 246 if data:
239 self.ui.debug(_("sending %s bytes\n") % 247 self.ui.debug(_("sending %s bytes\n") %
240 headers.get('content-length', 'X')) 248 headers.get('content-length', 'X'))
241 resp = urllib2.urlopen(urllib2.Request(cu, data, headers)) 249 resp = urllib2.urlopen(request(cu, data, headers))
242 except urllib2.HTTPError, inst: 250 except urllib2.HTTPError, inst:
243 if inst.code == 401: 251 if inst.code == 401:
244 raise util.Abort(_('authorization failed')) 252 raise util.Abort(_('authorization failed'))
245 raise 253 raise
246 except httplib.HTTPException, inst: 254 except httplib.HTTPException, inst: