comparison mod_rest/mod_rest.lua @ 3825:802087d3155a

mod_rest: Fix traceback on missing content-type header
author Kim Alvefur <zash@zash.se>
date Thu, 02 Jan 2020 09:59:31 +0100
parents a0b8ec44a36b
children 0d4146cf9fbc
comparison
equal deleted inserted replaced
3824:a0b8ec44a36b 3825:802087d3155a
23 local function check_credentials(request) 23 local function check_credentials(request)
24 return request.headers.authorization == secret; 24 return request.headers.authorization == secret;
25 end 25 end
26 26
27 local function parse(mimetype, data) 27 local function parse(mimetype, data)
28 mimetype = mimetype:match("^[^; ]*"); 28 mimetype = mimetype and mimetype:match("^[^; ]*");
29 if mimetype == "application/xmpp+xml" then 29 if mimetype == "application/xmpp+xml" then
30 return xml.parse(data); 30 return xml.parse(data);
31 elseif mimetype == "application/json" then 31 elseif mimetype == "application/json" then
32 local parsed, err = json.decode(data); 32 local parsed, err = json.decode(data);
33 if not parsed then 33 if not parsed then