Revision 39cfc25b
b/lib/http/__init__.py | ||
---|---|---|
81 | 81 |
""" |
82 | 82 |
|
83 | 83 |
|
84 |
class HttpConnectionClosed(Exception): |
|
85 |
"""Internal exception for a closed connection. |
|
86 |
|
|
87 |
This should only be used for internal error reporting. Only use |
|
88 |
it if there's no other way to report this condition. |
|
89 |
|
|
90 |
""" |
|
91 |
|
|
92 |
|
|
84 | 93 |
class HttpSocketTimeout(Exception): |
85 | 94 |
"""Internal exception for socket timeouts. |
86 | 95 |
|
... | ... | |
276 | 285 |
except OpenSSL.SSL.WantX509LookupError: |
277 | 286 |
continue |
278 | 287 |
|
288 |
except OpenSSL.SSL.ZeroReturnError, err: |
|
289 |
# SSL Connection has been closed. In SSL 3.0 and TLS 1.0, this only |
|
290 |
# occurs if a closure alert has occurred in the protocol, i.e. the |
|
291 |
# connection has been closed cleanly. Note that this does not |
|
292 |
# necessarily mean that the transport layer (e.g. a socket) has been |
|
293 |
# closed. |
|
294 |
if op == SOCKOP_SEND: |
|
295 |
# Can happen during a renegotiation |
|
296 |
raise HttpConnectionClosed(err.args) |
|
297 |
elif op == SOCKOP_RECV: |
|
298 |
return "" |
|
299 |
|
|
300 |
# SSL_shutdown shouldn't return SSL_ERROR_ZERO_RETURN |
|
301 |
raise socket.error(err.args) |
|
302 |
|
|
279 | 303 |
except OpenSSL.SSL.SysCallError, err: |
280 | 304 |
if op == SOCKOP_SEND: |
281 | 305 |
# arg1 is the data when writing |
... | ... | |
336 | 360 |
|
337 | 361 |
# Close the connection from our side |
338 | 362 |
try: |
363 |
# We don't care about the return value, see NOTES in SSL_shutdown(3). |
|
339 | 364 |
SocketOperation(poller, sock, SOCKOP_SHUTDOWN, socket.SHUT_RDWR, |
340 | 365 |
write_timeout) |
341 | 366 |
except HttpSocketTimeout: |
Also available in: Unified diff