tiny refactoring
This commit is contained in:
@@ -297,7 +297,7 @@ class WebSocket(object):
|
||||
self.sock.setsockopt(*opts)
|
||||
for opts in self.sockopt:
|
||||
self.sock.setsockopt(*opts)
|
||||
|
||||
|
||||
address = addrinfo[4]
|
||||
try:
|
||||
self.sock.connect(address)
|
||||
@@ -424,7 +424,7 @@ class WebSocket(object):
|
||||
r = r.lower()
|
||||
if v != r:
|
||||
return False
|
||||
|
||||
|
||||
if subprotocols:
|
||||
subproto = headers.get("sec-websocket-protocol", None)
|
||||
if not subproto or subproto not in subprotocols:
|
||||
@@ -456,10 +456,10 @@ class WebSocket(object):
|
||||
line = line.decode('utf-8').strip()
|
||||
if not line:
|
||||
break
|
||||
|
||||
|
||||
if traceEnabled:
|
||||
logger.debug(line)
|
||||
|
||||
|
||||
if not status:
|
||||
status_info = line.split(" ", 2)
|
||||
status = int(status_info[1])
|
||||
@@ -599,7 +599,7 @@ class WebSocket(object):
|
||||
|
||||
if frame.fin:
|
||||
self._recving_frames = None
|
||||
|
||||
|
||||
if frame.fin or self.fire_cont_frame:
|
||||
data = self._cont_data
|
||||
self._cont_data = None
|
||||
|
@@ -32,7 +32,6 @@ from websocket._utils import validate_utf8
|
||||
|
||||
# Skip test to access the internet.
|
||||
TEST_WITH_INTERNET = False
|
||||
# TEST_WITH_INTERNET = True
|
||||
|
||||
# Skip Secure WebSocket test.
|
||||
TEST_SECURE_WS = False
|
||||
@@ -480,7 +479,7 @@ class WebSocketAppTest(unittest.TestCase):
|
||||
close the connection.
|
||||
"""
|
||||
WebSocketAppTest.keep_running_open = self.keep_running
|
||||
|
||||
|
||||
self.close()
|
||||
|
||||
def on_close(self, *args, **kwargs):
|
||||
@@ -534,7 +533,7 @@ class SockOptTest(unittest.TestCase):
|
||||
class UtilsTest(unittest.TestCase):
|
||||
def testUtf8Validator(self):
|
||||
state = validate_utf8(six.b('\xf0\x90\x80\x80'))
|
||||
self.assertEqual(state, True)
|
||||
self.assertEqual(state, True)
|
||||
state = validate_utf8(six.b('\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5\xed\xa0\x80edited'))
|
||||
self.assertEqual(state, False)
|
||||
state = validate_utf8(six.b(''))
|
||||
@@ -569,9 +568,9 @@ class ProxyInfoTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(get_proxy_info("echo.websocket.org", False, http_proxy_host="localhost", http_proxy_auth=("a", "b")),
|
||||
("localhost", 0, ("a", "b")))
|
||||
self.assertEqual(get_proxy_info("echo.websocket.org", False, http_proxy_host="localhost", http_proxy_port=3128, http_proxy_auth=("a", "b")),
|
||||
self.assertEqual(get_proxy_info("echo.websocket.org", False, http_proxy_host="localhost", http_proxy_port=3128, http_proxy_auth=("a", "b")),
|
||||
("localhost", 3128, ("a", "b")))
|
||||
self.assertEqual(get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_auth=("a", "b")),
|
||||
self.assertEqual(get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_auth=("a", "b")),
|
||||
("localhost", 0, ("a", "b")))
|
||||
self.assertEqual(get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_port=3128, http_proxy_auth=("a", "b")),
|
||||
("localhost", 3128, ("a", "b")))
|
||||
@@ -634,6 +633,6 @@ class ProxyInfoTest(unittest.TestCase):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user