diff options
author | David Thompson <dthompson2@worcester.edu> | 2016-03-25 19:04:28 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-03-25 19:04:28 -0400 |
commit | e8c4c06420db8cb5ab1ee4bba6082a480d098e95 (patch) | |
tree | f9a23c7ff4be594d2ecf18c19643d4c939dba4da /web/socket/server.scm | |
parent | c4d4f854074dc2a021606119e797d68d8aa01168 (diff) |
Extract accept key generation to a new module.
* web/socket/server.scm (handshake): Moved.
(make-handshake-response): Use new make-accept-key procedure.
* web/socket/utils.scm: New file.
* Makefile.am (SOURCES): Add it.
Diffstat (limited to 'web/socket/server.scm')
-rw-r--r-- | web/socket/server.scm | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/web/socket/server.scm b/web/socket/server.scm index 04ab5d4..cd52220 100644 --- a/web/socket/server.scm +++ b/web/socket/server.scm @@ -30,23 +30,12 @@ #:use-module (web request) #:use-module (web response) #:use-module (web uri) - #:use-module (web socket base64) #:use-module (web socket frame) - #:use-module (web socket sha-1) + #:use-module (web socket utils) #:export (make-server-socket run-server)) ;; See section 4.2 for explanation of the handshake. -(define (handshake client-key) - "Translate the base64 encoded CLIENT-KEY string into a base64 -encoded acceptance key." - (base64-encode - (sha-1->bytevector - (sha-1 - (string->utf8 - (string-append (string-trim-both client-key) - "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")))))) - (define (read-handshake-request client-socket) "Read HTTP request from CLIENT-SOCKET that should contain the headers required for a WebSocket handshake." @@ -58,7 +47,7 @@ headers required for a WebSocket handshake." connection for the client whose key is CLIENT-KEY, a base64 encoded string." ;; See section 4.2.2. - (let ((accept-key (handshake client-key))) + (let ((accept-key (make-accept-key (string-trim-both client-key)))) (build-response #:code 101 #:headers `((upgrade . ("websocket")) (connection . (upgrade)) |