My agentic slop goes here. Not intended for anyone else!

more

Changed files
+104
stack
river
+46
stack/river/lib/client.ml
···
+
(*
+
* Copyright (c) 2014, OCaml.org project
+
* Copyright (c) 2015 KC Sivaramakrishnan <sk826@cl.cam.ac.uk>
+
*
+
* Permission to use, copy, modify, and distribute this software for any
+
* purpose with or without fee is hereby granted, provided that the above
+
* copyright notice and this permission notice appear in all copies.
+
*
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
*)
+
+
(* River HTTP client using Requests *)
+
+
let src = Logs.Src.create "river.client" ~doc:"River HTTP client"
+
module Log = (val Logs.src_log src : Logs.LOG)
+
+
type t = {
+
session : (float Eio.Time.clock_ty Eio.Resource.t,
+
[`Generic | `Unix] Eio.Net.ty Eio.Resource.t) Requests.t;
+
}
+
+
let create ~sw (env : _ ) =
+
Log.info (fun m -> m "Creating River client");
+
let session = Requests.create ~sw
+
~default_headers:(Requests.Headers.of_list [
+
("User-Agent", "OCaml-River/1.0");
+
])
+
~follow_redirects:true
+
~max_redirects:5
+
~verify_tls:true
+
env
+
in
+
{ session }
+
+
let with_client (env : _) f =
+
Eio.Switch.run @@ fun sw ->
+
let client = create ~sw env in
+
f client
+
+
let session t = t.session
+58
stack/river/lib/client.mli
···
+
(*
+
* Copyright (c) 2014, OCaml.org project
+
* Copyright (c) 2015 KC Sivaramakrishnan <sk826@cl.cam.ac.uk>
+
*
+
* Permission to use, copy, modify, and distribute this software for any
+
* purpose with or without fee is hereby granted, provided that the above
+
* copyright notice and this permission notice appear in all copies.
+
*
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
*)
+
+
(** River HTTP client using Requests library.
+
+
This module provides a session-based HTTP client for fetching RSS/Atom feeds.
+
The client manages a Requests session with appropriate defaults for feed fetching. *)
+
+
(** The type of a River HTTP client *)
+
type t
+
+
(** [create ~sw env] creates a new River client with a Requests session.
+
+
The session is configured with:
+
- User-Agent: "OCaml-River/1.0"
+
- Automatic redirect following (max 5 redirects)
+
- TLS verification enabled
+
+
@param sw The switch for resource management
+
@param env The Eio environment providing network and time resources *)
+
val create :
+
sw:Eio.Switch.t ->
+
< clock : float Eio.Time.clock_ty Eio.Resource.t;
+
fs : Eio.Fs.dir_ty Eio.Path.t;
+
net : [ `Generic | `Unix ] Eio.Net.ty Eio.Resource.t; .. > ->
+
t
+
+
(** [with_client env f] creates a client and automatically manages its lifecycle.
+
+
This is the recommended way to use the client as it ensures proper cleanup.
+
+
@param env The Eio environment
+
@param f The function to run with the client *)
+
val with_client :
+
< clock : float Eio.Time.clock_ty Eio.Resource.t;
+
fs : Eio.Fs.dir_ty Eio.Path.t;
+
net : [ `Generic | `Unix ] Eio.Net.ty Eio.Resource.t; .. > ->
+
(t -> 'a) -> 'a
+
+
(** [session t] returns the underlying Requests session.
+
+
This is used internally by River's HTTP functions. *)
+
val session : t -> (float Eio.Time.clock_ty Eio.Resource.t,
+
[`Generic | `Unix] Eio.Net.ty Eio.Resource.t) Requests.t