[tor-commits] [flashproxy/master] Move handling of close frames up a layer.

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


commit 1fabbac49024b6ca952e654e842ca178be5fe448
Author: David Fifield <david at bamsoftware.com>
Date:   Mon Nov 26 22:29:01 2012 -0800

    Move handling of close frames up a layer.
---
 websocket-transport/websocket-server.go |    4 ++++
 websocket-transport/websocket.go        |    4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/websocket-transport/websocket-server.go b/websocket-transport/websocket-server.go
index aadd602..fa07fe7 100644
--- a/websocket-transport/websocket-server.go
+++ b/websocket-transport/websocket-server.go
@@ -39,6 +39,10 @@ func (conn *websocketConn) Read(b []byte) (n int, err error) {
 		if err != nil {
 			return
 		}
+		if m.Opcode == 8 {
+			err = io.EOF
+			return
+		}
 		if conn.Base64 {
 			if m.Opcode != 1 {
 				err = errors.New(fmt.Sprintf("got non-text opcode %d with the base64 subprotocol", m.Opcode))
diff --git a/websocket-transport/websocket.go b/websocket-transport/websocket.go
index 53c25f7..70bd67d 100644
--- a/websocket-transport/websocket.go
+++ b/websocket-transport/websocket.go
@@ -170,10 +170,6 @@ func (ws *Websocket) ReadMessage() (message WebsocketMessage, err error) {
 				err = errors.New("control frame has fin bit unset")
 				return
 			}
-			if frame.Opcode == 8 {
-				err = io.EOF
-				return
-			}
 			message.Opcode = frame.Opcode
 			message.Payload = frame.Payload
 			return message, nil





More information about the tor-commits mailing list