1 # ezhttp/src/wire: one request out and one response back. TLS and DNS stay in 2 # the effect (OpenSSL via dlopen); this module does not re-specify TLS. 3 # 4 # Spec: scheme, host, port each on their own line; everything after the third 5 # newline is the request verbatim. Answer: status on the first line, then text 6 # ("0" and the raw response, or a non-zero code and the reason). 7 import Base 8 import ./wirespec.bend as Spec 9 10 # the exchange 11 def ezwire.talk(spec: String) -> IO(String): 12 import "./effs/wire.c" 13 import "./effs/wire.js" 14 15 # the spec the effect reads (wirespec.bend) 16 def wire.spec(secure: Bool, host: String, port: U32, req: String) -> String: 17 Spec.wire.spec(secure, host, port, req) 18 19 # a request sent to a host and its whole answer read back 20 def wire.talk(secure: Bool, host: String, port: U32, req: String) -> IO(String): 21 ezwire.talk(wire.spec(secure, host, port, req))