From 095487ce856897f1ae8481a6652741d0b65e4bc7 Mon Sep 17 00:00:00 2001 From: craff Date: Wed, 18 Jan 2023 17:06:25 -1000 Subject: [PATCH] close stream after Response.output --- src/Tiny_httpd_server.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Tiny_httpd_server.ml b/src/Tiny_httpd_server.ml index 673656cd..75438fe6 100644 --- a/src/Tiny_httpd_server.ml +++ b/src/Tiny_httpd_server.ml @@ -406,7 +406,12 @@ module Response = struct begin match body with | `String "" | `Void -> () | `String s -> output_string oc s; - | `Stream str -> Byte_stream.output_chunked oc str; + | `Stream str -> + try + Byte_stream.output_chunked oc str; + Byte_stream.close str + with + e -> Byte_stream.close str; raise e end; flush oc end