summaryrefslogtreecommitdiffstats
path: root/Lib/httplib.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-10-11 17:47:22 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-10-11 17:47:22 (GMT)
commit6459c8d067890a64fc526204ab7004f9c8fcfe98 (patch)
treebf5a147a8e36488bde476454096d9d05d11f403d /Lib/httplib.py
parente2adc6c205db6087b3a8f00a245cfb06905b8ae5 (diff)
downloadcpython-6459c8d067890a64fc526204ab7004f9c8fcfe98.zip
cpython-6459c8d067890a64fc526204ab7004f9c8fcfe98.tar.gz
cpython-6459c8d067890a64fc526204ab7004f9c8fcfe98.tar.bz2
Fix for SF buf #458835
Try to be systematic about dealing with socket and ssl exceptions in FakeSocket.makefile(). The previous version of the code caught all ssl errors and treated them as EOF, even though most of the errors don't mean EOF. An SSL error can mean on of three things: 1. The SSL/TLS connection was closed. 2. The operation should be retried. 3. An error occurred. Also, if a socket error occurred and the error was EINTR, retry the call. Otherwise, it was a legitimate error and the caller should receive the exception.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r--Lib/httplib.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index fa63787..cb06856 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -66,8 +66,9 @@ Req-started-unread-response _CS_REQ_STARTED <response_class>
Req-sent-unread-response _CS_REQ_SENT <response_class>
"""
-import socket
+import errno
import mimetools
+import socket
try:
from cStringIO import StringIO
@@ -604,8 +605,18 @@ class FakeSocket:
while 1:
try:
buf = self.__ssl.read()
- except socket.sslerror, msg:
- break
+ except socket.sslerror, err:
+ if (err[0] == socket.SSL_ERROR_WANT_READ
+ or err[0] == socket.SSL_ERROR_WANT_WRITE
+ or 0):
+ continue
+ if err[0] == socket.SSL_ERROR_ZERO_RETURN:
+ break
+ raise
+ except socket.error, err:
+ if err[0] = errno.EINTR:
+ continue
+ raise
if buf == '':
break
msgbuf.append(buf)