Show More
@@ -307,15 +307,28 b' class KeepAliveHandler:' | |||
|
307 | 307 | return r |
|
308 | 308 | |
|
309 | 309 | def _start_transaction(self, h, req): |
|
310 | headers = req.headers.copy() | |
|
311 | body = req.data | |
|
312 | if sys.version_info >= (2, 4): | |
|
313 | headers.update(req.unredirected_hdrs) | |
|
314 | 310 | try: |
|
315 | h.request(req.get_method(), req.get_selector(), body, headers) | |
|
316 | except socket.error, err: # XXX what error? | |
|
311 | if req.has_data(): | |
|
312 | data = req.get_data() | |
|
313 | h.putrequest('POST', req.get_selector()) | |
|
314 | if 'Content-type' not in req.headers: | |
|
315 | h.putheader('Content-type', | |
|
316 | 'application/x-www-form-urlencoded') | |
|
317 | if 'Content-length' not in req.headers: | |
|
318 | h.putheader('Content-length', '%d' % len(data)) | |
|
319 | else: | |
|
320 | h.putrequest('GET', req.get_selector()) | |
|
321 | except (socket.error), err: | |
|
317 | 322 | raise urllib2.URLError(err) |
|
318 | 323 | |
|
324 | for args in self.parent.addheaders: | |
|
325 | h.putheader(*args) | |
|
326 | for k, v in req.headers.items(): | |
|
327 | h.putheader(k, v) | |
|
328 | h.endheaders() | |
|
329 | if req.has_data(): | |
|
330 | h.send(data) | |
|
331 | ||
|
319 | 332 | class HTTPHandler(KeepAliveHandler, urllib2.HTTPHandler): |
|
320 | 333 | pass |
|
321 | 334 |
General Comments 0
You need to be logged in to leave comments.
Login now