summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--websocket/_app.py7
-rw-r--r--websocket/_exceptions.py1
-rw-r--r--websocket/_handshake.py2
-rw-r--r--websocket/_http.py5
-rw-r--r--websocket/_utils.py1
5 files changed, 13 insertions, 3 deletions
diff --git a/websocket/_app.py b/websocket/_app.py
index 2710ef8..e4e9f99 100644
--- a/websocket/_app.py
+++ b/websocket/_app.py
@@ -42,7 +42,7 @@ __all__ = ["WebSocketApp"]
class Dispatcher:
def __init__(self, app, ping_timeout):
- self.app = app
+ self.app = app
self.ping_timeout = ping_timeout
def read(self, sock, read_callback, check_callback):
@@ -56,7 +56,7 @@ class Dispatcher:
class SSLDispatcher:
def __init__(self, app, ping_timeout):
- self.app = app
+ self.app = app
self.ping_timeout = ping_timeout
def read(self, sock, read_callback, check_callback):
@@ -75,6 +75,7 @@ class SSLDispatcher:
r, w, e = select.select((sock, ), (), (), self.ping_timeout)
return r
+
class WebSocketApp(object):
"""
Higher level of APIs are provided.
@@ -179,7 +180,7 @@ class WebSocketApp(object):
http_no_proxy=None, http_proxy_auth=None,
skip_utf8_validation=False,
host=None, origin=None, dispatcher=None,
- suppress_origin = False, proxy_type=None):
+ suppress_origin=False, proxy_type=None):
"""
run event loop for WebSocket framework.
This loop is infinite loop and is alive during websocket is available.
diff --git a/websocket/_exceptions.py b/websocket/_exceptions.py
index b7a61d3..2070790 100644
--- a/websocket/_exceptions.py
+++ b/websocket/_exceptions.py
@@ -80,6 +80,7 @@ class WebSocketBadStatusException(WebSocketException):
self.status_code = status_code
self.resp_headers = resp_headers
+
class WebSocketAddressException(WebSocketException):
"""
If the websocket address info cannot be found, this exception will be raised.
diff --git a/websocket/_handshake.py b/websocket/_handshake.py
index 4650c55..9a727dc 100644
--- a/websocket/_handshake.py
+++ b/websocket/_handshake.py
@@ -86,6 +86,7 @@ def handshake(sock, hostname, port, resource, **options):
return handshake_response(status, resp, subproto)
+
def _pack_hostname(hostname):
# IPv6 address
if ':' in hostname:
@@ -164,6 +165,7 @@ def _get_resp_headers(sock, success_statuses=SUCCESS_STATUSES):
raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
return status, resp_headers
+
_HEADERS_TO_CHECK = {
"upgrade": "websocket",
"connection": "upgrade",
diff --git a/websocket/_http.py b/websocket/_http.py
index 29a699c..a8777de 100644
--- a/websocket/_http.py
+++ b/websocket/_http.py
@@ -64,6 +64,7 @@ class proxy_info(object):
self.auth = None
self.no_proxy = None
+
def _open_proxied_socket(url, options, proxy):
hostname, port, resource, is_secure = parse_url(url)
@@ -147,6 +148,10 @@ def _get_addrinfo_list(hostname, port, is_secure, proxy):
return addrinfo_list, False, None
else:
pport = pport and pport or 80
+ # when running on windows 10, the getaddrinfo used above
+ # returns a socktype 0. This generates an error exception:
+ # _on_error: exception Socket type must be stream or datagram, not 0
+ # Force the socket type to SOCK_STREAM
addrinfo_list = socket.getaddrinfo(phost, pport, 0, socket.SOCK_STREAM, socket.SOL_TCP)
return addrinfo_list, True, pauth
except socket.gaierror as e:
diff --git a/websocket/_utils.py b/websocket/_utils.py
index 8eddabf..32ee12e 100644
--- a/websocket/_utils.py
+++ b/websocket/_utils.py
@@ -32,6 +32,7 @@ class NoLock(object):
def __exit__(self, exc_type, exc_value, traceback):
pass
+
try:
# If wsaccel is available we use compiled routines to validate UTF-8
# strings.