package pidgio

  1. Overview
  2. Docs

Source file util.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(* Copyright (c) 2026, Cargocut and the Pidgio developers.
   All rights reserved.

   SPDX-License-Identifier: BSD-3-Clause *)

let jsonrpc ?id value =
  Pidgin.Repr.(
    record ([ "jsonrpc", string "2.0"; "id", option int id ] @ value))
;;

let line_as_content_length s =
  match String.split_on_char ':' s with
  | [ "Content-Length"; len ] -> int_of_string_opt (String.trim len)
  | _ -> None
;;