Ai_provider.Http_clientSourceHTTP client wrappers that apply Http_timeouts to cohttp calls.
These are the defence-in-depth layer around Cohttp_lwt_unix.Client.post and the response body stream. All provider implementations should use these instead of raw cohttp calls.
val post :
timeouts:Http_timeouts.t ->
provider:string ->
headers:Cohttp.Header.t ->
body:Cohttp_lwt.Body.t ->
Uri.t ->
(Cohttp.Response.t * Cohttp_lwt.Body.t) Lwt.tWraps Cohttp_lwt_unix.Client.post in Lwt_unix.with_timeout using timeouts.request_timeout. On expiry, fails with Provider_error.Provider_error (Timeout { phase = Request_headers; ... }) tagged with the given provider string.
val wrap_body_with_idle_timeout :
timeouts:Http_timeouts.t ->
provider:string ->
Cohttp_lwt.Body.t ->
string Lwt_stream.tConverts a cohttp body into a line stream (splits on LF, strips CR), with an inter-chunk idle timer from timeouts.stream_idle_timeout. The returned stream:
Lwt.async_exception_hook after the stream is closed, so bugs stay visible in logs.