@@ -11,6 +11,7 @@ ChangeLog
|
||||
- fix string formatting in exception (#196)
|
||||
- fix typo in README.rst (#197)
|
||||
- introduce on_data callback to pass data type. (#198)
|
||||
- WebSocketBadStatusException for Handshake error (#199)
|
||||
|
||||
- 0.32.0
|
||||
|
||||
|
@@ -31,18 +31,21 @@ class WebSocketException(Exception):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class WebSocketProtocolException(WebSocketException):
|
||||
"""
|
||||
If the webscoket protocol is invalid, this exception will be raised.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class WebSocketPayloadException(WebSocketException):
|
||||
"""
|
||||
If the webscoket payload is invalid, this exception will be raised.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class WebSocketConnectionClosedException(WebSocketException):
|
||||
"""
|
||||
If remote host closed the connection or some network error happened,
|
||||
@@ -50,12 +53,14 @@ class WebSocketConnectionClosedException(WebSocketException):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class WebSocketTimeoutException(WebSocketException):
|
||||
"""
|
||||
WebSocketTimeoutException will be raised at socket timeout during read/write data.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class WebSocketProxyException(WebSocketException):
|
||||
"""
|
||||
WebSocketProxyException will be raised when proxy error occured.
|
||||
@@ -63,3 +68,10 @@ class WebSocketProxyException(WebSocketException):
|
||||
pass
|
||||
|
||||
|
||||
class WebSocketBadStatusException(WebSocketException):
|
||||
"""
|
||||
WebSocketBadStatusException will be raised when we get bad handshake status code.
|
||||
"""
|
||||
def __init__(self, message, status_code):
|
||||
super(WebSocketBadStatusException, self).__init__(message % status_code)
|
||||
self.status_code = status_code
|
||||
|
@@ -108,7 +108,7 @@ def _get_handshake_headers(resource, host, port, options):
|
||||
def _get_resp_headers(sock, success_status=101):
|
||||
status, resp_headers = read_headers(sock)
|
||||
if status != success_status:
|
||||
raise WebSocketException("Handshake status %d" % status)
|
||||
raise WebSocketBadStatusException("Handshake status %d", status)
|
||||
return status, resp_headers
|
||||
|
||||
_HEADERS_TO_CHECK = {
|
||||
|
Reference in New Issue
Block a user