##// END OF EJS Templates
keepalive: fix 4f13ed6ee544, reintroduce unredirected_hdrs...
Patrick Mezard -
r8233:655c435e default
parent child Browse files
Show More
@@ -307,23 +307,31 b' class KeepAliveHandler:'
307 return r
307 return r
308
308
309 def _start_transaction(self, h, req):
309 def _start_transaction(self, h, req):
310 # What follows mostly reimplements HTTPConnection.request()
311 # except it adds self.parent.addheaders in the mix.
312 headers = req.headers.copy()
313 if sys.version_info >= (2, 4):
314 headers.update(req.unredirected_hdrs)
315 headers.update(self.parent.addheaders)
316 headers = dict((n.lower(), v) for n,v in headers.items())
317 skipheaders = {}
318 for n in ('host', 'accept-encoding'):
319 if n in headers:
320 skipheaders['skip_' + n.replace('-', '_')] = 1
310 try:
321 try:
311 if req.has_data():
322 if req.has_data():
312 data = req.get_data()
323 data = req.get_data()
313 h.putrequest('POST', req.get_selector())
324 h.putrequest('POST', req.get_selector(), **skipheaders)
314 if 'Content-type' not in req.headers:
325 if 'content-type' not in headers:
315 h.putheader('Content-type',
326 h.putheader('Content-type',
316 'application/x-www-form-urlencoded')
327 'application/x-www-form-urlencoded')
317 if 'Content-length' not in req.headers:
328 if 'content-length' not in headers:
318 h.putheader('Content-length', '%d' % len(data))
329 h.putheader('Content-length', '%d' % len(data))
319 else:
330 else:
320 h.putrequest('GET', req.get_selector())
331 h.putrequest('GET', req.get_selector(), **skipheaders)
321 except (socket.error), err:
332 except (socket.error), err:
322 raise urllib2.URLError(err)
333 raise urllib2.URLError(err)
323
334 for k, v in headers.items():
324 for args in self.parent.addheaders:
325 h.putheader(*args)
326 for k, v in req.headers.items():
327 h.putheader(k, v)
335 h.putheader(k, v)
328 h.endheaders()
336 h.endheaders()
329 if req.has_data():
337 if req.has_data():
General Comments 0
You need to be logged in to leave comments. Login now