def up.put

bend-kit-http@0.38.5.0 · http.bend:5472

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

5472# One write per chunk, so the size line and the data do not wait on each other (Nagle).
5473def up.put(+tls: Bool, s: Socket, +ms: U32, +head: Bool, +len: U32, piece: Bytes.Bytes, skip: Bool) -> IO(Up & Result<&2, &2, Err, Unit>):
5474  match skip:
5475    case True{}:
5476      IO.pure(Up & Result<&2, &2, Err, Unit>, (Up{tls, s, ms, head, None{}}, Done{Unit{}}))
5477    case False{}:
5478      do IO<Up & Result<&2, &2, Err, Unit>>:
5479        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{}}}}))
5480        return up.wrote(tls, ms, head, sent)

Uses (22)

Used by (1)