dymokomi/luce-std
Source of release 0.7.4
0.7.4 / tests / net_protocol_interop / main.luc
import protocols
pub func main(arguments: list[str]) -> int!:
let calculate = protocols.accept_key
let first = calculate("dGhlIHNhbXBsZSBub25jZQ==")
let second = calculate("AAAAAAAAAAAAAAAAAAAAAA==")
assert(first == "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=")
assert(second == "ICX+Yqv66kxgM0FcWaLWlFLwTAI=")
assert(protocols.content_length("POST / HTTP/1.1\r\nHost: example.test\r\nContent-Length: 7\r\n\r\n") == 7)
let copied = protocols.roundtrip("hello €")
_ = protocols.roundtrip("changed")
assert(copied == "hello €")
var rejected = false
_ = protocols.content_length("invalid") catch failure:
rejected = true
recover 0
assert(rejected)
print("ok Luce/Base HTTP and WebSocket boundary")
return 0