Changeset 1552
- Timestamp:
- 12/21/06 17:44:55
- Files:
-
- trunk/cherrypy/wsgiserver.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/wsgiserver.py
r1550 r1552 462 462 463 463 464 def _ssl_wrap_method(method): 464 def _ssl_wrap_method(method, is_reader=False): 465 """Wrap the given method with SSL error-trapping. 466 467 is_reader: if False (the default), EOF errors will be raised. 468 If True, EOF errors will return "" (to emulate normal sockets). 469 """ 465 470 def ssl_method_wrapper(self, *args, **kwargs): 466 471 ## print (id(self), method, args, kwargs) … … 476 481 time.sleep(self.ssl_retry) 477 482 except SSL.SysCallError, e: 478 if e.args == (-1, 'Unexpected EOF'):483 if is_reader and e.args == (-1, 'Unexpected EOF'): 479 484 return "" 480 485 481 486 errno = e.args[0] 482 if errno not in socket_errors_to_ignore: 483 raise socket.error(errno) 484 485 return "" 487 if is_reader and errno in socket_errors_to_ignore: 488 return "" 489 raise socket.error(errno) 486 490 except SSL.Error, e: 487 if e.args == (-1, 'Unexpected EOF'):491 if is_reader and e.args == (-1, 'Unexpected EOF'): 488 492 return "" 489 elife.args[0][0][2] == 'ssl handshake failure':493 if is_reader and e.args[0][0][2] == 'ssl handshake failure': 490 494 return "" 491 else: 492 raise 495 raise 493 496 if time.time() - start > self.ssl_timeout: 494 497 raise socket.timeout("timed out") … … 505 508 write = _ssl_wrap_method(socket._fileobject.write) 506 509 writelines = _ssl_wrap_method(socket._fileobject.writelines) 507 read = _ssl_wrap_method(socket._fileobject.read )508 readline = _ssl_wrap_method(socket._fileobject.readline )509 readlines = _ssl_wrap_method(socket._fileobject.readlines )510 read = _ssl_wrap_method(socket._fileobject.read, is_reader=True) 511 readline = _ssl_wrap_method(socket._fileobject.readline, is_reader=True) 512 readlines = _ssl_wrap_method(socket._fileobject.readlines, is_reader=True) 510 513 511 514

