Skip to content

Commit

Permalink
Fix the ownership of the given bs by the HTTP scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure authored and reynir committed Feb 2, 2023
1 parent 2bba6fb commit 267e239
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/http_lwt_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@ let single_http_1_1_request ?config fd user_pass host meth path headers body f f
in
let open Lwt.Infix in
let rec on_read on_eof acc bs ~off ~len =
(* XXX(dinosaure): we must do the copy before the [>>=].
[Httpaf] will re-use [bs] then. *)
let str = Bigstringaf.substring ~off ~len bs in
let acc =
acc >>= fun acc ->
f response acc (Bigstringaf.substring ~off ~len bs)
f response acc str
in
Httpaf.Body.schedule_read response_body
~on_read:(on_read on_eof acc)
Expand Down Expand Up @@ -189,9 +192,12 @@ let single_h2_request ?config fd scheme user_pass host meth path headers body f
} in
let open Lwt.Infix in
let rec on_read on_eof acc bs ~off ~len =
(* XXX(dinosaure): we must do the copy before the [>>=].
[H2] will re-use [bs] then. *)
let str = Bigstringaf.substring bs ~off ~len in
let acc =
acc >>= fun acc ->
f response acc (Bigstringaf.substring ~off ~len bs)
f response acc str
in
H2.Body.Reader.schedule_read response_body
~on_read:(on_read on_eof acc)
Expand Down

0 comments on commit 267e239

Please sign in to comment.