utils: do not emit eof chunk for 204/304 responses
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 27 Oct 2014 10:18:10 +0000 (11:18 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 27 Oct 2014 10:18:10 +0000 (11:18 +0100)
According to RFC2616 10.2.5 and 10.3.5, 204 and 304 responses MUST NOT contain any
message body, therfore do not emit an EOF chunk for such responses.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
utils.c

diff --git a/utils.c b/utils.c
index 1c21fc56eaddc555aac290000042ed2731411c4a..1092a7d23b57b95d97e839d560758cc42b25e13a 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -28,6 +28,10 @@ bool uh_use_chunked(struct client *cl)
        if (cl->request.method == UH_HTTP_MSG_HEAD || cl->request.method == UH_HTTP_MSG_OPTIONS)
                return false;
 
+       /* RFC2616 10.2.5, 10.3.5 */
+       if (cl->http_code == 204 || cl->http_code == 304)
+               return false;
+
        return true;
 }