Module Http.Range

Range requests.

Support for range requests.

Byte ranges

type bytes = [
  1. | `First of int
    (*

    First given offset to last offset

    *)
  2. | `Last of int
    (*

    At most last given n bytes.

    *)
  3. | `Range of int * int
    (*

    First offset and last offset.

    *)
]

The type for byte range specifications. Offsets are zero-based.

val eval_bytes : length:int -> bytes -> (int * int) option

eval_bytes ~length b given a representation length len and byte range b returns a concrete zero-based byte range or None if the range cannot be satisfied for length.

Ranges

type t = [
  1. | `Bytes of bytes list
    (*

    Byte ranges.

    *)
  2. | `Other of string * string
    (*

    Range unit and value.

    *)
]

The type for ranges.

val decode : string -> (t, string) Stdlib.result

decode s decodes a range header value.

val encode : t -> string

encode r serializes ranges r in unit u. It's the client duty to make sure ranges are valid.