def request
bend-kit-websocket@0.4.0.0 · websocket.bend:88
import bend-kit-websocket@0.4.0.0/websocket.bend as Websocket
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
88
89
90
91def request(+host: String, +path: String, +key: String) -> Result<&1, &1, U32 & String, Bytes.Bytes>:
92 verdict(Bytes.Bytes,
93 first(reject(Bool.or(String.is_empty(host), Bool.not(visible(host))), 22, "host is not visible ASCII"),
94 first(reject(Bool.or(Bool.not(String.starts_with(path, "/")), Bool.not(visible(path))), 22, "path is not an origin-form target"),
95 reject(Bool.or(String.is_empty(key), Bool.not(visible(key))), 22, "key is not visible ASCII"))),
96 Bytes.from_string("GET " ++ path ++ " HTTP/1.1\r\nHost: " ++ host
97 ++ "\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: " ++ key
98 ++ "\r\nSec-WebSocket-Version: 13\r\n\r\n"))