let lwt_stream_to_string lwt_stream =
let buf = Buffer.create 42 in
wrap_deferred ~on_exn:(fun e -> `Failure (Printexc.to_string e))
Lwt.(fun () ->
Lwt_stream.iter_s
(fun s -> Buffer.add_string buf s; return ()) lwt_stream)
>>= fun () ->
return (Buffer.contents buf)