12345678910111213141516171819202122232425(* This file is part of Dream, released under the MIT license. See LICENSE.md
for details, or visit https://github.com/aantron/dream.
Copyright 2021 Anton Bachin *)moduleMessage=Dream_pure.Message(* TODO Also mind Connection: close. *)(* TODO Test in integration with HTTP/2. *)(* TODO This could be renamed transfer_encoding at this point. *)(* Add a Content-Length header to HTTP 1.x responses that have a fixed body but
don't yet have the header. *)letcontent_lengthnext_handlerrequest=iffst(Message.versionrequest)<>1thennext_handlerrequestelselet%lwt(response:Message.response)=next_handlerrequestinifnot(Message.has_headerresponse"Transfer-Encoding")thenifnot(Message.has_headerresponse"Content-Length")thenMessage.add_headerresponse"Transfer-Encoding""chunked";Lwt.returnresponse