equal
deleted
inserted
replaced
73 userpass = urllib.quote(user) + ':' + urllib.quote(passwd) |
73 userpass = urllib.quote(user) + ':' + urllib.quote(passwd) |
74 else: |
74 else: |
75 userpass = urllib.quote(user) |
75 userpass = urllib.quote(user) |
76 return userpass + '@' + hostport |
76 return userpass + '@' + hostport |
77 return hostport |
77 return hostport |
|
78 |
|
79 # work around a bug in Python < 2.4.2 |
|
80 # (it leaves a "\n" at the end of Proxy-authorization headers) |
|
81 class request(urllib2.Request): |
|
82 def add_header(self, key, val): |
|
83 if key.lower() == 'proxy-authorization': |
|
84 val = val.strip() |
|
85 return urllib2.Request.add_header(self, key, val) |
78 |
86 |
79 class httpsendfile(file): |
87 class httpsendfile(file): |
80 def __len__(self): |
88 def __len__(self): |
81 return os.fstat(self.fileno()).st_size |
89 return os.fstat(self.fileno()).st_size |
82 |
90 |
237 cu = "%s%s" % (self._url, qs) |
245 cu = "%s%s" % (self._url, qs) |
238 try: |
246 try: |
239 if data: |
247 if data: |
240 self.ui.debug(_("sending %s bytes\n") % |
248 self.ui.debug(_("sending %s bytes\n") % |
241 headers.get('content-length', 'X')) |
249 headers.get('content-length', 'X')) |
242 resp = urllib2.urlopen(urllib2.Request(cu, data, headers)) |
250 resp = urllib2.urlopen(request(cu, data, headers)) |
243 except urllib2.HTTPError, inst: |
251 except urllib2.HTTPError, inst: |
244 if inst.code == 401: |
252 if inst.code == 401: |
245 raise util.Abort(_('authorization failed')) |
253 raise util.Abort(_('authorization failed')) |
246 raise |
254 raise |
247 except httplib.HTTPException, inst: |
255 except httplib.HTTPException, inst: |