From ffa40a67e35067b30525c2dd3492468ab644b561 Mon Sep 17 00:00:00 2001 From: Bikal Lem Date: Thu, 1 Sep 2022 14:24:41 +0100 Subject: [PATCH] eio(client) : fix #930 --- cohttp-eio/src/client.ml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cohttp-eio/src/client.ml b/cohttp-eio/src/client.ml index bfcf1e3a7e..341e4b67e8 100644 --- a/cohttp-eio/src/client.ml +++ b/cohttp-eio/src/client.ml @@ -116,13 +116,9 @@ let patch ?version ?headers ?body ~conn host resource_path = (* Response Body *) let read_fixed ((response, reader) : Http.Response.t * Buf_read.t) = - match - Http.Header.get response.headers "Content-Length" - |> Option.get - |> int_of_string - with - | content_length -> Buf_read.take content_length reader - | exception _ -> Buf_read.take_all reader + match Http.Response.content_length response with + | Some content_length -> Buf_read.take content_length reader + | None -> Buf_read.take_all reader let read_chunked : response -> (Body.chunk -> unit) -> Http.Header.t option = fun (response, reader) f -> Body.read_chunked reader response.headers f