From cf9188f78af8dee21294559f1a0a3886e637b3a6 Mon Sep 17 00:00:00 2001 From: Romain Calascibetta Date: Wed, 1 Feb 2023 12:38:01 +0100 Subject: [PATCH] Fix the ownership of the given bigstring by the underlying http scheduler --- src/http_mirage_client.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/http_mirage_client.ml b/src/http_mirage_client.ml index 97c6669..c921e2d 100644 --- a/src/http_mirage_client.ml +++ b/src/http_mirage_client.ml @@ -176,8 +176,9 @@ let single_http_1_1_request (Httpaf.Headers.to_list response.Httpaf.Response.headers) } in let rec on_read on_eof acc ba ~off ~len = + let str = Bigstringaf.substring ~off ~len ba in let acc = - acc >>= fun acc -> f response acc (Bigstringaf.substring ~off ~len ba) + acc >>= fun acc -> f response acc str in Httpaf.Body.schedule_read body ~on_read:(on_read on_eof acc) ~on_eof:(on_eof response acc) in @@ -230,8 +231,9 @@ let single_h2_request ; headers= response.H2.Response.headers } in let rec on_read on_eof acc ba ~off ~len = + let str = Bigstringaf.substring ~off ~len ba in let acc = - acc >>= fun acc -> f response acc (Bigstringaf.substring ~off ~len ba) + acc >>= fun acc -> f response acc str in H2.Body.Reader.schedule_read response_body ~on_read:(on_read on_eof acc) ~on_eof:(on_eof response acc) in