From 932f277b55351b2a2b284ecf375126280f2da54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20Edwin?= Date: Thu, 28 May 2015 23:00:33 +0300 Subject: [PATCH] Fix handling of 1xx/204/304: there is no message body Similar to the fix for the HEAD method. See http://tools.ietf.org/html/rfc7230#section-5.7.1 --- lib/response.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/response.ml b/lib/response.ml index 46ee84621c..8e5874dde6 100644 --- a/lib/response.ml +++ b/lib/response.ml @@ -64,7 +64,11 @@ module Make(IO : S.IO) = struct let flush = false in return (`Ok { encoding; headers; version; status; flush }) - let has_body {encoding} = Transfer.has_body encoding + let has_body {status; encoding} = + (* rfc7230#section-5.7.1 *) + match status with + | #Code.informational_status | `No_content | `Not_modified -> `No + | #Code.status_code -> Transfer.has_body encoding let make_body_reader {encoding} ic = Transfer_IO.make_reader encoding ic let read_body_chunk = Transfer_IO.read