BUG/MEDIUM: lua: HTTP services must take care of body-less status codes
authorWilly Tarreau <w@1wt.eu>
Wed, 23 Aug 2017 07:10:38 +0000 (09:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Aug 2017 14:11:38 +0000 (16:11 +0200)
commit06c75fec1783f1641b11f627be06f7df26e9d282
tree050ae5d5577c3675d4dd0d24b49c3d4cd9243352
parentd9587418867d86aa503c249272634139fe909cbf
BUG/MEDIUM: lua: HTTP services must take care of body-less status codes

The following Lua code causes emission of a final chunk after the body,
which is wrong :

core.register_service("send204", "http", function(applet)
   applet:set_status(204)
   applet:start_response()
end)

Indeed, responses with status codes 1xx, 204 and 304 do not contain any
body and the message ends immediately after the empty header (cf RFC7230)
so by emitting a 0<CR><LF> we're disturbing keep-alive responses. There's
a workaround against this for now which consists in always emitting
"Content-length: 0" but it may not be cool with 304 when clients use
the headers to update their cache.

This fix must be backported to stable versions back to 1.6.
src/hlua.c