def up.put

bend-kit-http@0.38.2.0 · http.bend:5480

import bend-kit-http@0.38.2.0/http.bend as Http
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

5480# One write per chunk, so the size line and the data do not wait on each other (Nagle).
5481def up.put(+tls: Bool, s: Socket, +ms: U32, +head: Bool, +len: U32, piece: Bytes.Bytes, skip: Bool) -> IO(Up & Result<&2, &2, Err, Unit>):
5482  match skip:
5483    case True{}:
5484      IO.pure(Up & Result<&2, &2, Err, Unit>, (Up{tls, s, ms, head, None{}}, Done{Unit{}}))
5485    case False{}:
5486      do IO<Up & Result<&2, &2, Err, Unit>>:
5487        sent : Socket & Result<&1, &1, U32 & String, Unit> <- io.send.bytes(tls, s, Bytes.concat(Con{Bytes.from_string(hex(len) ++ "\r\n"), Con{piece, Con{Bytes.from_string("\r\n"), Nil{}}}}))
5488        return up.wrote(tls, ms, head, sent)

Uses (22)

Used by (1)