Software /
code /
prosody-modules
Comparison
mod_pubsub_feed/mod_pubsub_feed.lua @ 402:c92a37a72b25
mod_pubsub_feed: Use httpserver.new_from_config(). Fixes SSL. And fix traceback when called without a querypart.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Aug 2011 15:55:49 +0200 |
parent | 401:c85397063eca |
child | 403:fc62b26dfdf6 |
comparison
equal
deleted
inserted
replaced
401:c85397063eca | 402:c92a37a72b25 |
---|---|
212 end); | 212 end); |
213 end | 213 end |
214 | 214 |
215 function handle_http_request(method, body, request) | 215 function handle_http_request(method, body, request) |
216 --module:log("debug", "%s request to %s%s with body %s", method, request.url.path, request.url.query and "?" .. request.url.query or "", #body > 0 and body or "empty"); | 216 --module:log("debug", "%s request to %s%s with body %s", method, request.url.path, request.url.query and "?" .. request.url.query or "", #body > 0 and body or "empty"); |
217 local query = request.url.query; | 217 local query = request.url.query or {}; |
218 if query and type(query) == "string" then | 218 if query and type(query) == "string" then |
219 query = urlparams(query); | 219 query = urlparams(query); |
220 --module:log("debug", "GET data: %s", dump(query)); | 220 --module:log("debug", "GET data: %s", dump(query)); |
221 end | 221 end |
222 --module:log("debug", "Headers: %s", dump(request.headers)); | 222 --module:log("debug", "Headers: %s", dump(request.headers)); |
243 module:log("debug", "Confirming %s request to %s", feed.subscription, feed.url) | 243 module:log("debug", "Confirming %s request to %s", feed.subscription, feed.url) |
244 return http_response(200, nil, query["hub.challenge"]) | 244 return http_response(200, nil, query["hub.challenge"]) |
245 end | 245 end |
246 return http_response(400); | 246 return http_response(400); |
247 elseif method == "POST" then | 247 elseif method == "POST" then |
248 -- TODO http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html#authednotify | |
249 if #body > 0 and feed_list[query.node] then | 248 if #body > 0 and feed_list[query.node] then |
250 module:log("debug", "got %d bytes PuSHed for %s", #body, query.node); | 249 module:log("debug", "got %d bytes PuSHed for %s", #body, query.node); |
251 local feed = feed_list[query.node]; | 250 local feed = feed_list[query.node]; |
252 local signature = request.headers["x-hub-signature"]; | 251 local signature = request.headers["x-hub-signature"]; |
253 if feed.secret then | 252 if feed.secret then |
269 end | 268 end |
270 | 269 |
271 function init() | 270 function init() |
272 module:log("debug", "initiating", module.name); | 271 module:log("debug", "initiating", module.name); |
273 if use_pubsubhubub then | 272 if use_pubsubhubub then |
274 httpserver.new{ port = port_number, base = base_name, handler = handle_http_request } | 273 module:log("debug", "Starting http server on %s", format_url(secure, http_hostname, port_number, base_name, "NODE")); |
274 --httpserver.new{ port = port_number, ssl = secure, type = (ssl and "ssl") or "tcp", base = base_name, handler = handle_http_request } | |
275 httpserver.new_from_config( ports, handle_http_request, { base = "callback" } ); | |
275 end | 276 end |
276 add_task(0, refresh_feeds); | 277 add_task(0, refresh_feeds); |
277 end | 278 end |
278 | 279 |
279 if prosody.start_time then -- already started | 280 if prosody.start_time then -- already started |