branch: externals/websocket commit ee44af2cc55415591e7ccb1007193294c702affd Merge: 69ee80a88b 74f00575b9 Author: Andrew Hyatt <ahy...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #65 from yuya373/fix-handshake-when-nowait Fix handshake when nowait. --- websocket.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket.el b/websocket.el index b2fe6d9612..a594c016a1 100644 --- a/websocket.el +++ b/websocket.el @@ -722,7 +722,7 @@ to the websocket protocol. conn (websocket-sentinel url conn key protocols extensions custom-header-alist nowait)) (set-process-query-on-exit-flag conn nil) - (websocket-ensure-handshake url conn key protocols extensions custom-header-alist) + (websocket-ensure-handshake url conn key protocols extensions custom-header-alist nowait) websocket)) (defun websocket-sentinel (url conn key protocols extensions custom-header-alist nowait) @@ -731,17 +731,18 @@ to the websocket protocol. (websocket-debug websocket "State change to %s" change) (let ((status (process-status process))) (when (and nowait (eq status 'open)) - (websocket-ensure-handshake url conn key protocols extensions custom-header-alist)) + (websocket-ensure-handshake url conn key protocols extensions custom-header-alist nowait)) (when (and (member status '(closed failed exit signal)) (not (eq 'closed (websocket-ready-state websocket)))) (websocket-try-callback 'websocket-on-close 'on-close websocket)))))) -(defun websocket-ensure-handshake (url conn key protocols extensions custom-header-alist) +(defun websocket-ensure-handshake (url conn key protocols extensions custom-header-alist nowait) (let ((url-struct (url-generic-parse-url url)) (websocket (process-get conn :websocket))) (when (and (eq 'connecting (websocket-ready-state websocket)) - (eq 'open (process-status conn))) + (memq (process-status conn) + (list 'run (if nowait 'connect 'open)))) (process-send-string conn (format "GET %s HTTP/1.1\r\n" (let ((path (url-filename url-struct)))