fixed #113
This commit is contained in:
@@ -208,7 +208,8 @@ ChangeLog
|
|||||||
|
|
||||||
- suppress close event message(#107)
|
- suppress close event message(#107)
|
||||||
- detect socket connection state(#109)
|
- detect socket connection state(#109)
|
||||||
- support for code and reason in on_close callback(#111 )
|
- support for code and reason in on_close callback(#111)
|
||||||
|
- continuation frame handling seems suspicious(#113)
|
||||||
|
|
||||||
- v0.18.0
|
- v0.18.0
|
||||||
|
|
||||||
|
@@ -684,7 +684,7 @@ class WebSocket(object):
|
|||||||
# 'NoneType' object has no attribute 'opcode'
|
# 'NoneType' object has no attribute 'opcode'
|
||||||
raise WebSocketException("Not a valid frame %s" % frame)
|
raise WebSocketException("Not a valid frame %s" % frame)
|
||||||
elif frame.opcode in (ABNF.OPCODE_TEXT, ABNF.OPCODE_BINARY, ABNF.OPCODE_CONT):
|
elif frame.opcode in (ABNF.OPCODE_TEXT, ABNF.OPCODE_BINARY, ABNF.OPCODE_CONT):
|
||||||
if frame.opcode == ABNF.OPCODE_CONT and not self._cont_data:
|
if not self.fire_cont_frame and frame.opcode == ABNF.OPCODE_CONT and not self._cont_data:
|
||||||
raise WebSocketException("Illegal frame")
|
raise WebSocketException("Illegal frame")
|
||||||
if self._cont_data:
|
if self._cont_data:
|
||||||
self._cont_data[1] += frame.data
|
self._cont_data[1] += frame.data
|
||||||
|
@@ -289,6 +289,27 @@ class WebSocketTest(unittest.TestCase):
|
|||||||
with self.assertRaises(ws.WebSocketConnectionClosedException):
|
with self.assertRaises(ws.WebSocketConnectionClosedException):
|
||||||
sock.recv()
|
sock.recv()
|
||||||
|
|
||||||
|
def testRecvWithFireEventOfFragmentation(self):
|
||||||
|
sock = ws.WebSocket(fire_cont_frame=True)
|
||||||
|
s = sock.sock = SockMock()
|
||||||
|
# OPCODE=TEXT, FIN=0, MSG="Brevity is "
|
||||||
|
s.add_packet(six.b("\x01\x8babcd#\x10\x06\x12\x08\x16\x1aD\x08\x11C"))
|
||||||
|
# OPCODE=TEXT, FIN=0, MSG="Brevity is "
|
||||||
|
s.add_packet(six.b("\x01\x8babcd#\x10\x06\x12\x08\x16\x1aD\x08\x11C"))
|
||||||
|
# OPCODE=CONT, FIN=1, MSG="the soul of wit"
|
||||||
|
s.add_packet(six.b("\x80\x8fabcd\x15\n\x06D\x12\r\x16\x08A\r\x05D\x16\x0b\x17"))
|
||||||
|
|
||||||
|
_, data = sock.recv_data()
|
||||||
|
self.assertEqual(data, six.b("Brevity is "))
|
||||||
|
_, data = sock.recv_data()
|
||||||
|
self.assertEqual(data, six.b("Brevity is "))
|
||||||
|
_, data = sock.recv_data()
|
||||||
|
self.assertEqual(data, six.b("the soul of wit"))
|
||||||
|
|
||||||
|
|
||||||
|
with self.assertRaises(ws.WebSocketConnectionClosedException):
|
||||||
|
sock.recv()
|
||||||
|
|
||||||
def testClose(self):
|
def testClose(self):
|
||||||
sock = ws.WebSocket()
|
sock = ws.WebSocket()
|
||||||
sock.sock = SockMock()
|
sock.sock = SockMock()
|
||||||
|
Reference in New Issue
Block a user