fixed some error
This commit is contained in:
@@ -30,7 +30,6 @@ if six.PY3:
|
|||||||
else:
|
else:
|
||||||
from base64 import encodestring as base64encode
|
from base64 import encodestring as base64encode
|
||||||
|
|
||||||
import os
|
|
||||||
import struct
|
import struct
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
@@ -254,6 +253,7 @@ class WebSocket(object):
|
|||||||
self.handshake_response = handshake(self.sock, *addrs, **options)
|
self.handshake_response = handshake(self.sock, *addrs, **options)
|
||||||
self.connected = True
|
self.connected = True
|
||||||
except:
|
except:
|
||||||
|
if self.sock:
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
self.sock = None
|
self.sock = None
|
||||||
raise
|
raise
|
||||||
|
@@ -23,6 +23,7 @@ Copyright (C) 2010 Hiroki Ohtani(liris)
|
|||||||
import six
|
import six
|
||||||
import socket
|
import socket
|
||||||
import errno
|
import errno
|
||||||
|
import os
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
from base64 import encodebytes as base64encode
|
from base64 import encodebytes as base64encode
|
||||||
@@ -64,7 +65,7 @@ def connect(url, options, proxy):
|
|||||||
|
|
||||||
if is_secure:
|
if is_secure:
|
||||||
if HAVE_SSL:
|
if HAVE_SSL:
|
||||||
sock = _ssl_socket(sock, options.sslopt)
|
sock = _ssl_socket(sock, options.sslopt, hostname)
|
||||||
else:
|
else:
|
||||||
raise WebSocketException("SSL not available.")
|
raise WebSocketException("SSL not available.")
|
||||||
|
|
||||||
@@ -116,7 +117,7 @@ def _open_socket(addrinfo_list, sockopt, timeout):
|
|||||||
return sock
|
return sock
|
||||||
|
|
||||||
|
|
||||||
def _ssl_socket(sock, sslopt):
|
def _ssl_socket(sock, sslopt, hostname):
|
||||||
sslopt = dict(cert_reqs=ssl.CERT_REQUIRED)
|
sslopt = dict(cert_reqs=ssl.CERT_REQUIRED)
|
||||||
certPath = os.path.join(
|
certPath = os.path.join(
|
||||||
os.path.dirname(__file__), "cacert.pem")
|
os.path.dirname(__file__), "cacert.pem")
|
||||||
|
@@ -20,7 +20,7 @@ Copyright (C) 2010 Hiroki Ohtani(liris)
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__all__ = ["HAVE_SSL", "SSLError"]
|
__all__ = ["HAVE_SSL", "ssl", "SSLError"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ssl
|
import ssl
|
||||||
|
Reference in New Issue
Block a user