[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ddd1650: Version 1.6, mostly fixes for fragmented headers.
From: |
Andrew Hyatt |
Subject: |
[elpa] master ddd1650: Version 1.6, mostly fixes for fragmented headers. |
Date: |
Tue, 10 May 2016 03:29:40 +0000 (UTC) |
branch: master
commit ddd1650c918e6f7ce4ed94a0f1b83d873d0438a7
Author: Andrew Hyatt <address@hidden>
Commit: Andrew Hyatt <address@hidden>
Version 1.6, mostly fixes for fragmented headers.
* websocket.el (websocket-verify-response-code, websocket-outer-filter):
Fix handling of fragmented headers.
* websocket.el (websocket-server): Accept host for listening on.
* websocket-functional-test.el: Stop stopping the listener process on
Windows.
---
packages/websocket/websocket-functional-test.el | 8 ++++-
packages/websocket/websocket.el | 39 ++++++++++++++---------
2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/packages/websocket/websocket-functional-test.el
b/packages/websocket/websocket-functional-test.el
index 6a9481f..1bbd190 100644
--- a/packages/websocket/websocket-functional-test.el
+++ b/packages/websocket/websocket-functional-test.el
@@ -79,7 +79,10 @@
(websocket-close wstest-ws)
(assert (null (websocket-openp wstest-ws)))
-(stop-process wstest-server-proc)
+(if (not (eq system-type 'windows-nt))
+ ; Windows doesn't have support for the SIGSTP signal, so we'll just kill
+ ; the process.
+ (stop-process wstest-server-proc))
(kill-process wstest-server-proc)
;; Make sure the processes are closed. This happens asynchronously,
@@ -93,6 +96,8 @@
(when (>= (string-to-int (substring emacs-version 0 2)) 24)
(message "Testing with wss://echo.websocket.org")
+ (when (eq system-type 'windows-nt)
+ (message "Windows users must have gnutls DLLs in the emacs bin
directory."))
(setq wstest-ws
(websocket-open
"wss://echo.websocket.org"
@@ -123,6 +128,7 @@
(setq wstest-closed nil)
(setq server-conn (websocket-server
9998
+ :host 'local
:on-message (lambda (ws frame)
(message "Server received text!")
(websocket-send-text ws
diff --git a/packages/websocket/websocket.el b/packages/websocket/websocket.el
index 1b0b294..8cd51ae 100644
--- a/packages/websocket/websocket.el
+++ b/packages/websocket/websocket.el
@@ -4,7 +4,7 @@
;; Author: Andrew Hyatt <address@hidden>
;; Keywords: Communication, Websocket, Server
-;; Version: 1.5
+;; Version: 1.6
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
@@ -450,10 +450,11 @@ ERR should be a cons of error symbol and error data."
The only acceptable one to websocket is responce code 101.
A t value will be returned on success, and an error thrown
if not."
- (string-match "HTTP/1.1 \\([[:digit:]]+\\)" output)
+ (unless (string-match "^HTTP/1.1 \\([[:digit:]]+\\)" output)
+ (signal 'websocket-invalid-header "Invalid HTTP status line"))
(unless (equal "101" (match-string 1 output))
- (signal 'websocket-received-error-http-response
- (string-to-number (match-string 1 output))))
+ (signal 'websocket-received-error-http-response
+ (string-to-number (match-string 1 output))))
t)
(defun websocket-parse-repeated-field (output field)
@@ -746,19 +747,21 @@ connection is invalid, the connection will be closed."
(setf (websocket-inflight-input websocket) nil)
;; If we've received the complete header, check to see if we've
;; received the desired handshake.
- (when (and (eq 'connecting (websocket-ready-state websocket))
- (setq header-end-pos (string-match "\r\n\r\n" text))
+ (when (and (eq 'connecting (websocket-ready-state websocket)))
+ (if (and (setq header-end-pos (string-match "\r\n\r\n" text))
(setq start-point (+ 4 header-end-pos)))
- (condition-case err
(progn
- (websocket-verify-response-code text)
- (websocket-verify-headers websocket text)
- (websocket-process-headers (websocket-url websocket) text))
- (error
- (websocket-close websocket)
- (signal (car err) (cdr err))))
- (setf (websocket-ready-state websocket) 'open)
- (websocket-try-callback 'websocket-on-open 'on-open websocket))
+ (condition-case err
+ (progn
+ (websocket-verify-response-code text)
+ (websocket-verify-headers websocket text)
+ (websocket-process-headers (websocket-url websocket) text))
+ (error
+ (websocket-close websocket)
+ (signal (car err) (cdr err))))
+ (setf (websocket-ready-state websocket) 'open)
+ (websocket-try-callback 'websocket-on-open 'on-open websocket))
+ (setf (websocket-inflight-input websocket) text)))
(when (eq 'open (websocket-ready-state websocket))
(websocket-process-input-on-open-ws
websocket (substring text (or start-point 0))))))
@@ -820,6 +823,11 @@ of populating the list of server extensions to WEBSOCKET."
(defun* websocket-server (port &rest plist)
"Open a websocket server on PORT.
+If the plist contains a `:host' HOST pair, this value will be
+used to configure the addresses the socket listens on. The symbol
+`local' specifies the local host. If unspecified or nil, the
+socket will listen on all addresses.
+
This also takes a plist of callbacks: `:on-open', `:on-message',
`:on-close' and `:on-error', which operate exactly as documented
in the websocket client function `websocket-open'. Returns the
@@ -833,6 +841,7 @@ connection, which should be kept in order to pass to
:log 'websocket-server-accept
:filter-multibyte nil
:plist plist
+ :host (plist-get plist :host)
:service port)))
conn))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master ddd1650: Version 1.6, mostly fixes for fragmented headers.,
Andrew Hyatt <=