From 4da55bcedf111f3d0fbaf1e1b8eb3dfa51488348 Mon Sep 17 00:00:00 2001 From: Clombrong Date: Tue, 17 Jun 2025 20:54:24 +0200 Subject: feat(stream): wrap Lwt_stream.get to support ClosedStream exception --- lib/sasl.ml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/sasl.ml') diff --git a/lib/sasl.ml b/lib/sasl.ml index 3c2ae20..088543b 100644 --- a/lib/sasl.ml +++ b/lib/sasl.ml @@ -47,12 +47,9 @@ let send_auth_stanza (stream, push) localpart pass mechanism = `Text [gen_auth mechanism]; `End_element] in Markup.(stanza_list |> of_list |> write_xml |> to_string) |> Option.some |> push; - let* response = Lwt_stream.get stream - in try - match response with - | Some stanza -> parse_sasl_response stanza |> Lwt.return - | None -> Lwt.fail Stream.ClosedStream - with exn -> Lwt.fail exn + let* response = Stream.get stream + in try parse_sasl_response response |> Lwt.return + with exn -> Lwt.fail exn let authenticate (portal : Portal.t) (config : auth_config) = let {jid; password; _} = config -- cgit v1.2.3