ocaml-cohttp
ocaml-cohttp copied to clipboard
cohttp_async pipelined HEAD requests with callv hang
The issue seems to be that Cohttp_async.Client.read_request
delegates to read
from Cohttp.Make
, which (roughly) parses the Content-Length
header to determine the encoding
. Assuming the server didn't send back a chunked encoding (I'm not even sure if that would make sense), then that results in an encoding of Fixed nL
where n
is the value of Content-Length
. It then tries to read that amount from the request. But, of course, since this is a HEAD, there is no actual body and that causes things to hang up.
The relevant section of RFC7230 is 3.3.2 about the handling of Content-Length
.
I noticed that this probably doesn't affect Cohttp_lwt
(although I haven't tested) as it has explicit code in Cohttp_lwt.Client
to pass along the method to the response reader and treat HEAD differently.
This could be fixed similarly in Cohttp_async
, but I think a more proper fix would be to push this logic down into make_body_reader
from Cohttp.Make
and have it give back either a nop body reader or some kind of variant describing the fact that the given request doesn't need a body reader that then the runtime specific libraries can take action on.