Skip to content

Commit c518768

Browse files
committed
FEAT: using built in WebSocket handshake function in the test server
1 parent bae6cff commit c518768

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

src/modules/httpd.reb

-2
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,6 @@ sys/make-scheme [
423423
ctx/out/header/Upgrade: "websocket"
424424
ctx/out/header/Connection: "Upgrade"
425425
ctx/out/header/Sec-WebSocket-Accept: enbase checksum join key "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" 'sha1 64
426-
;? ctx/out/header
427-
;ctx/out/content: ""
428426
]
429427
]
430428
]

src/tests/test-httpd.r3

+2-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Rebol [
1616
secure [%../modules/ allow]
1717
do %../modules/httpd.reb
1818

19-
system/options/log/httpd: 4 ; for verbose output
19+
system/options/log/httpd: 1 ; for verbose output
2020
system/options/quiet: false
2121

2222
; make sure that there is the directory for logs
@@ -32,18 +32,6 @@ humans.txt: {
3232
\____________/~~~> http://github.com/oldes/
3333
}
3434

35-
WS-handshake: func[ctx /local key][
36-
if all [
37-
"websocket" = select ctx/inp/header 'Upgrade
38-
key: select ctx/inp/header 'Sec-WebSocket-Key
39-
][
40-
ctx/out/status: 101
41-
ctx/out/header/Upgrade: "websocket"
42-
ctx/out/header/Connection: "Upgrade"
43-
ctx/out/header/Sec-WebSocket-Accept: enbase checksum join key "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" 'sha1 64
44-
]
45-
]
46-
4735
http-server/config/actor 8081 [
4836
;- Main server configuration
4937

@@ -131,7 +119,7 @@ http-server/config/actor 8081 [
131119
%/echo [
132120
;@@ Consider checking the ctx/out/header/Origin value
133121
;@@ before accepting websocket connection upgrade!
134-
WS-handshake ctx
122+
system/schemes/httpd/actor/WS-handshake ctx
135123
]
136124
]
137125
]

0 commit comments

Comments
 (0)