Skip to content

Commit

Permalink
FEAT: using built in WebSocket handshake function in the test server
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Dec 6, 2022
1 parent bae6cff commit c518768
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 0 additions & 2 deletions src/modules/httpd.reb
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,6 @@ sys/make-scheme [
ctx/out/header/Upgrade: "websocket"
ctx/out/header/Connection: "Upgrade"
ctx/out/header/Sec-WebSocket-Accept: enbase checksum join key "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" 'sha1 64
;? ctx/out/header
;ctx/out/content: ""
]
]
]
Expand Down
16 changes: 2 additions & 14 deletions src/tests/test-httpd.r3
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Rebol [
secure [%../modules/ allow]
do %../modules/httpd.reb

system/options/log/httpd: 4 ; for verbose output
system/options/log/httpd: 1 ; for verbose output
system/options/quiet: false

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

WS-handshake: func[ctx /local key][
if all [
"websocket" = select ctx/inp/header 'Upgrade
key: select ctx/inp/header 'Sec-WebSocket-Key
][
ctx/out/status: 101
ctx/out/header/Upgrade: "websocket"
ctx/out/header/Connection: "Upgrade"
ctx/out/header/Sec-WebSocket-Accept: enbase checksum join key "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" 'sha1 64
]
]

http-server/config/actor 8081 [
;- Main server configuration

Expand Down Expand Up @@ -131,7 +119,7 @@ http-server/config/actor 8081 [
%/echo [
;@@ Consider checking the ctx/out/header/Origin value
;@@ before accepting websocket connection upgrade!
WS-handshake ctx
system/schemes/httpd/actor/WS-handshake ctx
]
]
]
Expand Down

0 comments on commit c518768

Please sign in to comment.