Module Httpaf.Body
val schedule_read : [ `read ] t -> on_eof:(unit -> unit) -> on_read:(Bigstringaf.t -> off:int -> len:int -> unit) -> unit
schedule_read t ~on_eof ~on_read
will setupon_read
andon_eof
as callbacks for when bytes are available int
for the application to consume, or when the input channel has been closed and no further bytes will be received by the application.Once either of these callbacks have been called, they become inactive. The application is responsible for scheduling subsequent reads, either within the
on_read
callback or by some other mechanism.
val write_char : [ `write ] t -> char -> unit
write_char w char
copieschar
into an internal buffer. If possible, this write will be combined with previous and/or subsequent writes before transmission.
val write_string : [ `write ] t -> ?off:int -> ?len:int -> string -> unit
write_string w ?off ?len str
copiesstr
into an internal buffer. If possible, this write will be combined with previous and/or subsequent writes before transmission.
val write_bigstring : [ `write ] t -> ?off:int -> ?len:int -> Bigstringaf.t -> unit
write_bigstring w ?off ?len bs
copiesbs
into an internal buffer. If possible, this write will be combined with previous and/or subsequent writes before transmission.
val schedule_bigstring : [ `write ] t -> ?off:int -> ?len:int -> Bigstringaf.t -> unit
schedule_bigstring w ?off ?len bs
schedulesbs
to be transmitted at the next opportunity without performing a copy.bs
should not be modified until a subsequent call toflush
has successfully completed.
val flush : [ `write ] t -> (unit -> unit) -> unit
flush t f
makes all bytes int
available for writing to the awaiting output channel. Once those bytes have reached that output channel,f
will be called.The type of the output channel is runtime-dependent, as are guarantees about whether those packets have been queued for delivery or have actually been received by the intended recipient.
val close_reader : [ `read ] t -> unit
close_reader t
closest
, indicating that any subsequent input received should be discarded.
val close_writer : [ `write ] t -> unit
close_writer t
closest
, causing subsequent write calls to raise. Ift
is writable, this will cause any pending output to become available to the output channel.
val is_closed : _ t -> bool
is_closed t
istrue
ifclose
has been called ont
andfalse
otherwise. A closedt
may still have pending output.