[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 76/119: and more web-socket progress
From: |
Eric Schulte |
Subject: |
[elpa] 76/119: and more web-socket progress |
Date: |
Mon, 10 Mar 2014 16:57:42 +0000 |
eschulte pushed a commit to branch master
in repository elpa.
commit 02addb0cf99f2ca6568e18f1eac0f95afa6e9ed7
Author: Eric Schulte <address@hidden>
Date: Tue Jan 7 01:03:30 2014 -0700
and more web-socket progress
---
examples/9-web-socket.el | 1 +
web-server.el | 20 ++++++++++++++------
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/examples/9-web-socket.el b/examples/9-web-socket.el
index 3406596..62e6d33 100644
--- a/examples/9-web-socket.el
+++ b/examples/9-web-socket.el
@@ -35,6 +35,7 @@ function close(){ ws.close(); };
(cons "Sec-WebSocket-Accept"
(ws-web-socket-handshake
(cdr (assoc :SEC-WEBSOCKET-KEY headers)))))
+ (set-process-plist process (list :pending ""))
(set-process-coding-system process 'binary)
(set-process-filter process 'ws-web-socket-filter)
:keep-alive)
diff --git a/web-server.el b/web-server.el
index 69b0e01..fad4c83 100644
--- a/web-server.el
+++ b/web-server.el
@@ -357,7 +357,8 @@ See RFC6455."
(apply #'append
(mapcar (lambda (int) (int-to-bits int 8))
(subseq string index (incf index
length))))))
- (let (fin rsvs opcode mask pl mask-key data)
+ (let ((data (plist-get (process-plist proc) :pending))
+ fin rsvs opcode mask pl mask-key)
(let ((byte (bits 1)))
(setq fin (car byte)
rsvs (subseq byte 1 4)
@@ -370,18 +371,25 @@ See RFC6455."
(9 :PING)
(10 :PONG)
((11 12 13 14 15) :CONTROL)
- (t (ws-error proc "Bad opcode %d" ))))))
+ (t (ws-error proc "Web Socket Fail: bad opcode %d"
+ it))))))
+ (unless (cl-every #'null rsvs)
+ (ws-error proc "Web Socket Fail: non-zero RSV 1 2 or 3"))
(let ((byte (bits 1)))
(setq mask (car byte)
pl (bits-to-int (subseq byte 1))))
+ (unless (eq mask t)
+ (ws-error proc "Web Socket Fail: client must mask data"))
(cond
((= pl 126) (setq pl (bits-to-int (bits 2))))
((= pl 127) (setq pl (bits-to-int (bits 8)))))
(when mask (setq mask-key (subseq string index (incf index 4))))
- (setq data (subseq string index (+ index pl)))
- (message "fin:%s rsvs:%s opcode:%s mask-key:%s mask:%s pl:%s data:%S"
- fin rsvs opcode mask mask-key pl
- (ws/web-socket-mask mask-key data))))))
+ (setq data (concat data
+ (ws/web-socket-mask
+ mask-key (subseq string index (+ index pl)))))
+ (if fin
+ (message "received message %S" data)
+ (set-process-plist proc (list :data data)))))))
;;; Convenience functions to write responses
- [elpa] 64/119: fix file header, (continued)
- [elpa] 64/119: fix file header, Eric Schulte, 2014/03/10
- [elpa] 65/119: handle POST file uploads w/example, Eric Schulte, 2014/03/10
- [elpa] 66/119: notes, Eric Schulte, 2014/03/10
- [elpa] 70/119: run all tests with "make check", Eric Schulte, 2014/03/10
- [elpa] 67/119: test large file upload (w/o network chunking), Eric Schulte, 2014/03/10
- [elpa] 69/119: refactoring no multiple concurrent header parsing, Eric Schulte, 2014/03/10
- [elpa] 71/119: updating notes and README text, Eric Schulte, 2014/03/10
- [elpa] 72/119: notes for running behind an Apache HTTPS proxy, Eric Schulte, 2014/03/10
- [elpa] 73/119: some more examples to implement, Eric Schulte, 2014/03/10
- [elpa] 68/119: no multiple concurrent entry of ws-parse-request, Eric Schulte, 2014/03/10
- [elpa] 76/119: and more web-socket progress,
Eric Schulte <=
- [elpa] 74/119: beginning to implement web-socket support, Eric Schulte, 2014/03/10
- [elpa] 77/119: handle chunked receipt of web-socket messages, Eric Schulte, 2014/03/10
- [elpa] 78/119: hold, Eric Schulte, 2014/03/10
- [elpa] 79/119: beginning to add convenience macro for web sockets, Eric Schulte, 2014/03/10
- [elpa] 81/119: implemented ws-web-socket-frame to send replies, Eric Schulte, 2014/03/10
- [elpa] 80/119: helpers for handling web socket connections, Eric Schulte, 2014/03/10
- [elpa] 82/119: web-sockets are working, Eric Schulte, 2014/03/10
- [elpa] 84/119: more examples, Eric Schulte, 2014/03/10
- [elpa] 85/119: renaming example files, Eric Schulte, 2014/03/10
- [elpa] 86/119: another example idea -- org export service, Eric Schulte, 2014/03/10