# HG changeset patch # User jbe # Date 1434659933 -7200 # Node ID 77d8fdd124e6276eb91e682da7ac0b8c3e7ae9d5 # Parent f6eea95879d406e493d6a9813872b0520b71f30b Throw error if key is not a string when accessing headers table diff -r f6eea95879d4 -r 77d8fdd124e6 moonbridge_http.lua --- a/moonbridge_http.lua Thu Jun 18 22:35:52 2015 +0200 +++ b/moonbridge_http.lua Thu Jun 18 22:38:53 2015 +0200 @@ -246,16 +246,17 @@ -- (raw access, but case-insensitive): headers = setmetatable({}, { __index = function(self, key) - if type(key) == "string" then - local lowerkey = string.lower(key) - local result = rawget(self, lowerkey) - if result == nil then - result = {} - rawset(self, lowerkey, result) - end - rawset(self, key, result) - return result + if type(key) ~= "string" then + error("Attempted to index headers table with a non-string key") end + local lowerkey = string.lower(key) + local result = rawget(self, lowerkey) + if result == nil then + result = {} + rawset(self, lowerkey, result) + end + rawset(self, key, result) + return result end }), -- table mapping header field names to value-lists