##// END OF EJS Templates
Work around a urllib2 bug in Python < 2.4.2...
Alexis S. L. Carvalho -
r4226:fffacca4 default
parent child Browse files
Show More
@@ -76,6 +76,14 b' def netlocunsplit(host, port, user=None,'
76 return userpass + '@' + hostport
76 return userpass + '@' + hostport
77 return hostport
77 return hostport
78
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)
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
@@ -239,7 +247,7 b' class httprepository(remoterepository):'
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'))
General Comments 0
You need to be logged in to leave comments. Login now