Skip to content

Commit

Permalink
Merge branch 'binary-frames-closing-handshake' into hybi-10
Browse files Browse the repository at this point in the history
  • Loading branch information
wulczer committed Jul 31, 2011
2 parents 288e59f + 846bcdd commit a9baf98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test_websocket.py
Expand Up @@ -519,12 +519,12 @@ def test_binaryAndTextSplitted(self):
self.assertFalse(self.channel.transport.disconnected)


def text_maxBinaryLength(self):
def test_maxBinaryLength(self):
"""
If a binary frame's declared length exceeds MAX_BINARY_LENGTH, the
connection is dropped.
"""
self.decoder.dataReceived("\xff\xff\xff\xff\xff\xff")
self.decoder.dataReceived("\xff\xff\xff\xff\xff\x01")
self.assertTrue(self.channel.transport.disconnected)


Expand Down
5 changes: 3 additions & 2 deletions websocket.py
Expand Up @@ -730,12 +730,13 @@ def _consumeData_PARSING_LENGTH(self, data):

self._currentFrameLength *= 128
self._currentFrameLength += length
if self._currentFrameLength > self.MAX_BINARY_LENGTH:
self.handler.frameLengthExceeded()

current += 1

if not more:
if self._currentFrameLength > self.MAX_BINARY_LENGTH:
self.handler.frameLengthExceeded()

remainingData = data[current:]
self._addRemainingData(remainingData)
self._state = "PARSING_BINARY_FRAME"
Expand Down

0 comments on commit a9baf98

Please sign in to comment.