[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/websocket 4ca406fb96 060/114: Merge branch 'custom-head
From: |
ELPA Syncer |
Subject: |
[elpa] externals/websocket 4ca406fb96 060/114: Merge branch 'custom-headers' |
Date: |
Wed, 15 Feb 2023 20:59:00 -0500 (EST) |
branch: externals/websocket
commit 4ca406fb962cc36ac5712a19566b52c6a56d5238
Merge: 33d0406901 058e8f4696
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>
Merge branch 'custom-headers'
---
websocket-test.el | 14 +++++++++-----
websocket.el | 20 +++++++++++++++-----
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/websocket-test.el b/websocket-test.el
index 604eb87919..cfb2db00fd 100644
--- a/websocket-test.el
+++ b/websocket-test.el
@@ -207,18 +207,22 @@
(host localpart secure) ""))
(should (equal (concat base-headers "\r\n")
(websocket-create-headers "ws://www.example.com/path"
- "key" nil nil)))
+ "key" nil nil nil)))
(should (equal (concat base-headers
"Sec-WebSocket-Protocol: protocol\r\n\r\n")
(websocket-create-headers "ws://www.example.com/path"
- "key" '("protocol") nil)))
+ "key" '("protocol") nil nil)))
(should (equal
(concat base-headers
"Sec-WebSocket-Extensions: ext1; a; b=2, ext2\r\n\r\n")
(websocket-create-headers "ws://www.example.com/path"
"key" nil
'(("ext1" . ("a" "b=2"))
- ("ext2"))))))
+ ("ext2")) nil)))
+ (should (equal
+ (concat base-headers "Foo: bar\r\nBaz: boo\r\n\r\n")
+ (websocket-create-headers "ws://www.example.com/path"
+ "key" nil nil '(("Foo" . "bar")
("Baz" . "boo"))))))
(flet ((url-cookie-generate-header-lines
(host localpart secure)
(should (equal host "www.example.com:123"))
@@ -226,7 +230,7 @@
(should secure)
"Cookie: foo=bar\r\n"))
(should (equal (websocket-create-headers "wss://www.example.com:123/path"
- "key" nil nil)
+ "key" nil nil nil)
(concat
"Host: www.example.com:123\r\n"
"Upgrade: websocket\r\n"
@@ -237,7 +241,7 @@
(should
(string-match
"Host: www.example.com:123\r\n"
- (websocket-create-headers "ws://www.example.com:123/path" "key" nil
nil)))))
+ (websocket-create-headers "ws://www.example.com:123/path" "key" nil nil
nil)))))
(ert-deftest websocket-process-headers ()
(flet ((url-cookie-handle-set-cookie
diff --git a/websocket.el b/websocket.el
index 854e69c9fa..355e70b962 100644
--- a/websocket.el
+++ b/websocket.el
@@ -610,7 +610,7 @@ connecting or open."
(cl-defun websocket-open (url &key protocols extensions (on-open 'identity)
(on-message (lambda (_w _f))) (on-close 'identity)
(on-error 'websocket-default-error-handler)
- (nowait nil))
+ (nowait nil) (custom-header-alist nil))
"Open a websocket connection to URL, returning the `websocket' struct.
The PROTOCOL argument is optional, and setting it will declare to
the server that this client supports the protocols in the list
@@ -683,6 +683,11 @@ describing the problem with the frame.
`nowait': If NOWAIT is true, return without waiting for the
connection to complete.
+
+`custom-headers-alist': An alist of custom headers to pass to the
+server. The car is the header name, the cdr is the header value.
+These are different from the extensions because it is not related
+to the websocket protocol.
"
(let* ((name (format "websocket to %s" url))
(url-struct (url-generic-parse-url url))
@@ -738,7 +743,8 @@ connection to complete.
(websocket-debug websocket "Sending handshake, key: %s, acceptance: %s"
key (websocket-accept-string websocket))
(process-send-string conn
- (websocket-create-headers url key protocols
extensions))
+ (websocket-create-headers
+ url key protocols extensions custom-header-alist))
(websocket-debug websocket "Websocket opened")
websocket))
@@ -906,9 +912,10 @@ connection, which should be kept in order to pass to
(not (eq 'closed (websocket-ready-state websocket))))
(websocket-try-callback 'websocket-on-close 'on-close
websocket)))))))
-(defun websocket-create-headers (url key protocol extensions)
- "Create connections headers for the given URL, KEY, PROTOCOL and EXTENSIONS.
-These are defined as in `websocket-open'."
+(defun websocket-create-headers (url key protocol extensions
custom-headers-alist)
+ "Create connections headers for the given URL, KEY, PROTOCOL, and EXTENSIONS.
+Additionally, the CUSTOM-HEADERS-ALIST is passed from the client.
+All these parameters are defined as in `websocket-open'."
(let* ((parsed-url (url-generic-parse-url url))
(host-port (if (url-port-if-non-default parsed-url)
(format "%s:%s" (url-host parsed-url) (url-port
parsed-url))
@@ -939,6 +946,9 @@ These are defined as in `websocket-open'."
(mapconcat 'identity (cdr ext) "; "))))
extensions ", ")))
(when cookie-header cookie-header)
+ (concat (mapconcat (lambda (cons) (format "%s: %s" (car
cons) (cdr cons)))
+ custom-headers-alist "\r\n")
+ (when custom-headers-alist "\r\n"))
"\r\n")
host-port
key
- [elpa] externals/websocket 542c6fec74 025/114: Add support for cookies handling for ws clients., (continued)
- [elpa] externals/websocket 542c6fec74 025/114: Add support for cookies handling for ws clients., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 6b43f7525f 031/114: Add test for fragmented header, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket bcbd5258b2 040/114: Add note to windows users for functional tests., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket d407c0ad0f 041/114: Update version to 1.6., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 8f55a95698 042/114: Fix indentation., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket f94d43b97c 046/114: Prevent emacs from asking users about killing server process on exit, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket fbd9e2263d 047/114: Merge pull request #47 from alpha22jp/master, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket a9b8e74fa1 048/114: Update version to 1.8, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket f7f7ad6d45 052/114: when nowait, delay handshake after process move to open status, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 13520c8baa 054/114: add documentation for nowait, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 4ca406fb96 060/114: Merge branch 'custom-headers',
ELPA Syncer <=
- [elpa] externals/websocket b3a0153c0b 063/114: remove long line lambda, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket e9d148fbb6 064/114: Merge pull request #52 from yuya373/fix-nowait, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 607355db44 067/114: rename to `websocket-ensure-handshake`, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 0d96ba2ff5 069/114: Merge fix for 32-bit emacs., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket a5a3ddb5ca 072/114: Fix all signal calls., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket ef1e504fec 075/114: Fix tests broken by recent changes., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket da237af723 076/114: Fix confusing documentation string in `websocket-openp'., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 53bfd56e12 078/114: Upgrade version number to 1.11., ELPA Syncer, 2023/02/15
- [elpa] externals/websocket de8073d667 079/114: Is encode-coding-string (quote utf-8) necessary?, ELPA Syncer, 2023/02/15
- [elpa] externals/websocket 73eb210eb0 081/114: Merge pull request #59 from dickmao/state-change, ELPA Syncer, 2023/02/15