Changeset

5404:ae9a47e579d7

net.http.server: Don't overwrite existing response.headers when returning a response object from a HTTP handler (waqas says it's wrong)
author Matthew Wild <mwild1@gmail.com>
date Sun, 31 Mar 2013 13:45:04 +0100
parents 5403:d7ecf6cd584e
children 5405:4f98f2f60e22
files net/http/server.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/http/server.lua	Sun Mar 31 13:43:12 2013 +0100
+++ b/net/http/server.lua	Sun Mar 31 13:45:04 2013 +0100
@@ -219,7 +219,13 @@
 				body = result;
 			elseif result_type == "table" then
 				for k, v in pairs(result) do
-					response[k] = v;
+					if k ~= "headers" then
+						response[k] = v;
+					else
+						for header_name, header_value in pairs(v) do
+							response.headers[header_name] = header_value;
+						end
+					end
 				end
 			end
 			response:send(body);