package shuttle_http

  1. Overview
  2. Docs
module Stream : sig ... end

Stream represents streaming HTTP bodies. This module provides utilities to create and consume streams, while enforcing the invariant that only one consume can read from a stream, and that a stream can only be consumed once.

type t = private
  1. | Empty
  2. | Fixed of string
  3. | Stream of Stream.t
val sexp_of_t : t -> Sexplib0.Sexp.t
val string : string -> t

string str creates a fixed length encoded body from a user provided string.

val empty : t

empty is a zero length body.

val of_pipe : [ `Chunked | `Fixed of int ] -> string Async.Pipe.Reader.t -> t

of_pipe is a convenience function that creates a streaming body from a user provided Async_kernel.Pipe.Reader.t. The pipe will be closed whenever the streaming body is closed, or EOF is reached.

val stream : Stream.t -> t

stream creates a streaming body from a user provided streaming module.

val to_stream : t -> Stream.t

to_stream converts a HTTP body to a stream.


Innovation. Community. Security.