def wire.after.shake

emerging-ezhttp@0.21.0.0 · src/wire.bend:174

import emerging-ezhttp@0.21.0.0/src/wire.bend as Wire
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
import emerging-ezhttp@0.21.0.0/src/wirespec.bend as Spec

174# after the handshake: send, or the handshake's failure (the socket closed
175# plainly, as no TLS session was made)
176def wire.after.shake(+secure: Bool, +host: String, +port: U32, +ms: U32,
177  +method: String, payload: Bytes.Bytes,
178  r: Socket & Result<&1, &1, U32 & String, Unit>) -> IO(Answer):
179  (s, res) = r
180  match res:
181    case Fail{(n, why)}:
182      IO.bind(Unit, Answer, Socket.close(s),
183        _u => IO.pure(Answer,
184          Failed{Spec.wire.fail(Spec.Handshake{}, host, port, ms, n, why)}))
185    case Done{_u}:
186      wire.put(secure, s, host, port, ms, method, payload)

Uses (17)

Used by (1)