[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/websocket 6da0627a10 002/114: Correctly set websocket-s
From: |
ELPA Syncer |
Subject: |
[elpa] externals/websocket 6da0627a10 002/114: Correctly set websocket-server-p, and don't mask server communication. |
Date: |
Wed, 15 Feb 2023 20:58:55 -0500 (EST) |
branch: externals/websocket
commit 6da0627a10e4ad7dc108bf5d29b18b278d2a2592
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>
Correctly set websocket-server-p, and don't mask server communication.
This follows the requirements in the spec.
---
websocket.el | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/websocket.el b/websocket.el
index c01e3da183..b1d8e6fe5e 100644
--- a/websocket.el
+++ b/websocket.el
@@ -111,11 +111,6 @@ URL of the connection.")
"The websocket GUID as defined in RFC 6455.
Do not change unless the RFC changes.")
-(defvar websocket-mask-frames t
- "If true, we mask frames as defined in the spec.
-This is recommended to be true, and some servers will refuse to
-communicate with unmasked clients.")
-
(defvar websocket-callback-debug-on-error nil
"If true, when an error happens in a client callback, invoke the debugger.
Having this on can cause issues with missing frames if the debugger is
@@ -295,13 +290,14 @@ Otherwise we throw the error
`websocket-incomplete-frame'."
(when (< (length s) n)
(throw 'websocket-incomplete-frame nil)))
-(defun websocket-encode-frame (frame)
- "Encode the FRAME struct to the binary representation."
+(defun websocket-encode-frame (frame should-mask)
+ "Encode the FRAME struct to the binary representation.
+We mask the frame or not, depending on SHOULD-MASK."
(let* ((opcode (websocket-frame-opcode frame))
(payload (websocket-frame-payload frame))
(fin (websocket-frame-completep frame))
(payloadp (memq opcode '(continuation text binary)))
- (mask-key (when websocket-mask-frames (websocket-genbytes 4))))
+ (mask-key (when should-mask (websocket-genbytes 4))))
(apply 'unibyte-string
(append (list
(logior (cond ((eq opcode 'continuation) 0)
@@ -314,7 +310,7 @@ Otherwise we throw the error `websocket-incomplete-frame'."
(when payloadp
(list
(logior
- (if websocket-mask-frames 128 0)
+ (if should-mask 128 0)
(cond ((< (length payload) 126) (length payload))
((< (length payload) 65536) 126)
(t 127)))))
@@ -323,11 +319,10 @@ Otherwise we throw the error
`websocket-incomplete-frame'."
(cond ((< (length payload) 126) 1)
((< (length payload) 65536) 2)
(t 8))) nil))
- (when (and payloadp websocket-mask-frames)
+ (when (and payloadp should-mask)
(append mask-key nil))
(when payloadp
- (append (if websocket-mask-frames
- (websocket-mask mask-key payload)
+ (append (if should-mask (websocket-mask mask-key payload)
payload)
nil))))))
@@ -542,7 +537,8 @@ the `websocket-error' condition."
(unless (websocket-openp websocket)
(signal 'websocket-closed frame))
(process-send-string (websocket-conn websocket)
- (websocket-encode-frame frame)))
+ ;; We mask only when we're a client, following the spec.
+ (websocket-encode-frame frame (not (websocket-server-p
websocket)))))
(defun websocket-openp (websocket)
"Check WEBSOCKET and return non-nil if it is open, and either
@@ -827,6 +823,7 @@ connection, which should be kept in order to pass to
:server-conn server
:conn client
:url client
+ :server-p t
:on-open (or (process-get server :on-open) 'identity)
:on-message (or (process-get server :on-message) (lambda (_ws
_frame)))
:on-close (lexical-let ((user-method
- [elpa] externals/websocket updated (1f086f14f0 -> 2c923eba75), ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 07867563de 001/114: Don't assume any change to the process is bad - check before closing., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 2bfc3036f6 004/114: Handle on-close for all varieties of websocket closings., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 0dd3175fa7 003/114: Fix tests to handle extra argument to websocket-encode-frame., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 5f7decd210 006/114: Fix for on-close in websocket test, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 4ca9d4d32a 009/114: Set the version to 1.2, after the last set of server changes., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket f902bc04db 010/114: * websocket.el: Fix process-coding-system for client connections., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 6da0627a10 002/114: Correctly set websocket-server-p, and don't mask server communication.,
ELPA Syncer <=
- [elpa] externals/websocket ee7797234b 012/114: * websocket.el: Throw clear error when connection cannot be made., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket ef975a91f1 008/114: Restore a bit of testing I accidentally deleted., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 8d0ca79cd3 036/114: Have functional test use :host 'local, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 97b7418dae 013/114: Permit non-numeric port number in websocket-server, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 28e55d5654 015/114: Fix misuse of same-origin policy, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket b9ae25843a 016/114: Fix breaking test., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 01c8d98f69 011/114: * websocket.el: Remove use of buffers in connections. This simplifies, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 111febe203 020/114: Fix `websocket-version': update to 1.3, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 9aad2f754f 022/114: Add supports for <32 bit emacs., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket dba6893ec5 023/114: Bump version to 1.4, ELPA Syncer, 2023/02/15