[tor-commits] [flashproxy/master] Use a default MaxMessageSize.

dcf at torproject.org dcf at torproject.org
Wed Jan 30 05:11:38 UTC 2013


commit 4122f3f3af02255dd6cea07eef1ee33fc9083195
Author: David Fifield <david at bamsoftware.com>
Date:   Mon Nov 26 22:25:22 2012 -0800

    Use a default MaxMessageSize.
---
 websocket-transport/websocket.go |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/websocket-transport/websocket.go b/websocket-transport/websocket.go
index 5409ea6..53c25f7 100644
--- a/websocket-transport/websocket.go
+++ b/websocket-transport/websocket.go
@@ -41,14 +41,6 @@ type WebsocketConfig struct {
 	MaxMessageSize int
 }
 
-// Return the WebSocket's maximum message size, or a default maximum size.
-func (config *WebsocketConfig) maxMessageSize() int {
-	if config.MaxMessageSize == 0 {
-		return 64000
-	}
-	return config.MaxMessageSize
-}
-
 // Representation of a WebSocket frame. The Payload is always without masking.
 type WebsocketFrame struct {
 	Fin     bool
@@ -89,6 +81,13 @@ func applyMask(payload []byte, maskKey [4]byte) {
 	}
 }
 
+func (ws *Websocket) maxMessageSize() int {
+	if ws.MaxMessageSize == 0 {
+		return 64000
+	}
+	return ws.MaxMessageSize
+}
+
 // Read a single frame from the WebSocket.
 func (ws *Websocket) ReadFrame() (frame WebsocketFrame, err error) {
 	var b byte
@@ -120,7 +119,7 @@ func (ws *Websocket) ReadFrame() (frame WebsocketFrame, err error) {
 		}
 		payloadLen = long
 	}
-	if payloadLen > uint64(ws.MaxMessageSize) {
+	if payloadLen > uint64(ws.maxMessageSize()) {
 		err = errors.New(fmt.Sprintf("frame payload length of %d exceeds maximum of %d", payloadLen, ws.MaxMessageSize))
 		return
 	}





More information about the tor-commits mailing list