equal
deleted
inserted
replaced
229 |
229 |
230 local function handle_request(event, path) |
230 local function handle_request(event, path) |
231 local request, response = event.request, event.response; |
231 local request, response = event.request, event.response; |
232 local from; |
232 local from; |
233 local origin; |
233 local origin; |
|
234 local echo = path == "echo"; |
|
235 if echo then path = nil; end |
234 |
236 |
235 if not request.headers.authorization then |
237 if not request.headers.authorization then |
236 response.headers.www_authenticate = www_authenticate_header; |
238 response.headers.www_authenticate = www_authenticate_header; |
237 return post_errors.new("noauthz"); |
239 return post_errors.new("noauthz"); |
238 else |
240 else |
283 ["xml:lang"] = payload.attr["xml:lang"], |
285 ["xml:lang"] = payload.attr["xml:lang"], |
284 }; |
286 }; |
285 |
287 |
286 module:log("debug", "Received[rest]: %s", payload:top_tag()); |
288 module:log("debug", "Received[rest]: %s", payload:top_tag()); |
287 local send_type = decide_type((request.headers.accept or "") ..",".. (request.headers.content_type or ""), supported_outputs) |
289 local send_type = decide_type((request.headers.accept or "") ..",".. (request.headers.content_type or ""), supported_outputs) |
|
290 |
|
291 if echo then |
|
292 response.headers.content_type = send_type; |
|
293 return encode(send_type, payload); |
|
294 end |
|
295 |
288 if payload.name == "iq" then |
296 if payload.name == "iq" then |
289 function origin.send(stanza) |
297 function origin.send(stanza) |
290 module:send(stanza); |
298 module:send(stanza); |
291 end |
299 end |
292 |
300 |