comparison mod_rest/mod_rest.lua @ 4245:7bf3bf81c9ef

mod_rest: Use HTTP error mapping from net.http.errors This was basically a subset
author Kim Alvefur <zash@zash.se>
date Sun, 15 Nov 2020 15:17:50 +0100
parents 07c11080027e
children 1f93fa24611d
comparison
equal deleted inserted replaced
4244:07c11080027e 4245:7bf3bf81c9ef
291 send_type = decide_type(response.headers.accept, supported_outputs); 291 send_type = decide_type(response.headers.accept, supported_outputs);
292 module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type); 292 module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type);
293 end 293 end
294 end); 294 end);
295 295
296 local code2err = { 296 local code2err = require "net.http.errors".registry;
297 [400] = { condition = "bad-request"; type = "modify" };
298 [401] = { condition = "not-authorized"; type = "auth" };
299 [402] = { condition = "not-authorized"; type = "auth" };
300 [403] = { condition = "forbidden"; type = "auth" };
301 [404] = { condition = "item-not-found"; type = "cancel" };
302 [406] = { condition = "not-acceptable"; type = "modify" };
303 [408] = { condition = "remote-server-timeout"; type = "wait" };
304 [409] = { condition = "conflict"; type = "cancel" };
305 [410] = { condition = "gone"; type = "cancel" };
306 [411] = { condition = "bad-request"; type = "modify" };
307 [412] = { condition = "bad-request"; type = "modify" };
308 [413] = { condition = "resource-constraint"; type = "modify" };
309 [414] = { condition = "resource-constraint"; type = "modify" };
310 [415] = { condition = "bad-request"; type = "modify" };
311 [429] = { condition = "resource-constraint"; type = "wait" };
312 [431] = { condition = "resource-constraint"; type = "wait" };
313
314 [500] = { condition = "internal-server-error"; type = "cancel" };
315 [501] = { condition = "feature-not-implemented"; type = "modify" };
316 [502] = { condition = "remote-server-timeout"; type = "wait" };
317 [503] = { condition = "service-unavailable"; type = "cancel" };
318 [504] = { condition = "remote-server-timeout"; type = "wait" };
319 [507] = { condition = "resource-constraint"; type = "wait" };
320 };
321 297
322 local function handle_stanza(event) 298 local function handle_stanza(event)
323 local stanza, origin = event.stanza, event.origin; 299 local stanza, origin = event.stanza, event.origin;
324 local reply_needed = stanza.name == "iq"; 300 local reply_needed = stanza.name == "iq";
325 local receipt; 301 local receipt;