def check
bend-kit-websocket@0.4.0.0 · websocket.bend:208
import bend-kit-websocket@0.4.0.0/websocket.bend as Websocket
import Base
208
209
210
211def check(+head: String, +want: String) -> Result<&1, &1, U32 & String, Unit>:
212 verdict(Unit,
213 first(reject(Bool.not(status(String.split(head, '\n'))), 1002, "status line is not HTTP/1.1 101"),
214 first(reject(Bool.not(lines.ok(headers(head))), 1002, "malformed header line"),
215 first(reject(Bool.not(value.is(value.lower(field(head, "upgrade")), "websocket")), 1002, "Upgrade is not one websocket"),
216 first(reject(Bool.not(tokens(fields(head, "connection"), "upgrade")), 1002, "Connection lacks Upgrade"),
217 first(reject(Bool.not(value.is(field(head, "sec-websocket-accept"), want)), 1002, "Sec-WebSocket-Accept is not one match for the key"),
218 first(reject(Bool.not(none(fields(head, "sec-websocket-extensions"))), 1002, "unrequested extension"),
219 reject(Bool.not(none(fields(head, "sec-websocket-protocol"))), 1002, "unrequested subprotocol"))))))),
220 Unit{})