Turbo is a framework built for LuaJIT 2 to simplify the task of building fast and scalable network applications. It uses a event-driven, non-blocking, no thread design to deliver excellent performance and minimal footprint to high-load applications while also providing excellent support for embedded uses.
turbo/web.lua: overwrite Content-Type header instead of adding new one when returning json
This change prevents the web server from returning 2 "Content-Type" headers instead of one
if a "Content-Type" header was already added as one of the default headers (in
turbo.web.RequestHandler:set_default_headers). Now there will be one Content-Type header at
most.
The reason is that it is useful to set as default header "Content-type: text/plain" when
you want to return that content (and not the default text/html) for 4xx and 5xx return codes
while returning json for 200. Without the present commit, in the happy path (200 return code),
the web server returned 2 Content-type headers (text/plain and application/json).
turbo/web.lua: overwrite Content-Type header instead of adding new one when returning json
This change prevents the web server from returning 2 "Content-Type" headers instead of one if a "Content-Type" header was already added as one of the default headers (in turbo.web.RequestHandler:set_default_headers). Now there will be one Content-Type header at most.
The reason is that it is useful to set as default header "Content-type: text/plain" when you want to return that content (and not the default text/html) for 4xx and 5xx return codes while returning json for 200. Without the present commit, in the happy path (200 return code), the web server returned 2 Content-type headers (text/plain and application/json).