Show More
@@ -307,23 +307,31 b' class KeepAliveHandler:' | |||
|
307 | 307 | return r |
|
308 | 308 | |
|
309 | 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 | 321 | try: |
|
311 | 322 | if req.has_data(): |
|
312 | 323 | data = req.get_data() |
|
313 | h.putrequest('POST', req.get_selector()) | |
|
314 |
if ' |
|
|
324 | h.putrequest('POST', req.get_selector(), **skipheaders) | |
|
325 | if 'content-type' not in headers: | |
|
315 | 326 | h.putheader('Content-type', |
|
316 | 327 | 'application/x-www-form-urlencoded') |
|
317 |
if ' |
|
|
328 | if 'content-length' not in headers: | |
|
318 | 329 | h.putheader('Content-length', '%d' % len(data)) |
|
319 | 330 | else: |
|
320 | h.putrequest('GET', req.get_selector()) | |
|
331 | h.putrequest('GET', req.get_selector(), **skipheaders) | |
|
321 | 332 | except (socket.error), err: |
|
322 | 333 | raise urllib2.URLError(err) |
|
323 | ||
|
324 | for args in self.parent.addheaders: | |
|
325 | h.putheader(*args) | |
|
326 | for k, v in req.headers.items(): | |
|
334 | for k, v in headers.items(): | |
|
327 | 335 | h.putheader(k, v) |
|
328 | 336 | h.endheaders() |
|
329 | 337 | if req.has_data(): |
General Comments 0
You need to be logged in to leave comments.
Login now