My agentic slop goes here. Not intended for anyone else!
1(*
2 * Copyright (c) 2014, OCaml.org project
3 * Copyright (c) 2015 KC Sivaramakrishnan <sk826@cl.cam.ac.uk>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 *)
17
18(* River HTTP client using Requests *)
19
20let src = Logs.Src.create "river.client" ~doc:"River HTTP client"
21module Log = (val Logs.src_log src : Logs.LOG)
22
23type t = {
24 session : Requests.t;
25}
26
27let create ~sw (env : _ ) =
28 Log.info (fun m -> m "Creating River client");
29 let session = Requests.create ~sw
30 ~default_headers:(Requests.Headers.of_list [
31 ("User-Agent", "OCaml-River/1.0");
32 ])
33 ~follow_redirects:true
34 ~max_redirects:5
35 ~verify_tls:true
36 env
37 in
38 { session }
39
40let with_client (env : _) f =
41 Eio.Switch.run @@ fun sw ->
42 let client = create ~sw env in
43 f client
44
45let session t = t.session