hunchensocket
hunchensocket copied to clipboard
pending opcode is not reset properly
The pending-opcode slot in a client is not reset properly after receiving a data message. The result is that whatever type of message (text or binary) is received first, all subsequent messages will be received as that same type regardless of their actual type.
This seems to fix the problem:
diff --git a/hunchensocket.lisp b/hunchensocket.lisp
index df3797a..902f684 100644
--- a/hunchensocket.lisp
+++ b/hunchensocket.lisp
@@ -411,7 +411,7 @@ format control and arguments."
(t
(websocket-error
1002 "Client sent unknown opcode ~a" opcode))))
- (setf pending-fragments nil))
+ (setf pending-fragments nil pending-opcode nil))
((eq +ping+ opcode)
;; Reply to client-initiated ping with a server-pong with the
;; same data
This seems to make a lot of sense at first sight. Can you submit this as a pull request?
Receiving binary messages fails anyway with "Binaries not accepted" error, if I remove the error in check-message it appears to work.