comparison mod_pubsub_feeds/mod_pubsub_feeds.lua @ 983:ac9bf3fcbcfe

mod_pubsub_feeds, mod_sms_clickatell, mod_twitter: Update for net.http API change in prosody:e3b9dc9dd940
author Matthew Wild <mwild1@gmail.com>
date Fri, 12 Apr 2013 00:33:41 +0100
parents 68a067d5ed3b
children 04cf0b75fe2a
comparison
equal deleted inserted replaced
982:ce8bb0386d08 983:ac9bf3fcbcfe
127 function fetch(item, callback) -- HTTP Pull 127 function fetch(item, callback) -- HTTP Pull
128 local headers = { }; 128 local headers = { };
129 if item.data and item.last_update then 129 if item.data and item.last_update then
130 headers["If-Modified-Since"] = date("!%a, %d %b %Y %H:%M:%S %Z", item.last_update); 130 headers["If-Modified-Since"] = date("!%a, %d %b %Y %H:%M:%S %Z", item.last_update);
131 end 131 end
132 http.request(item.url, { headers = headers }, function(data, code, req) 132 http.request(item.url, { headers = headers }, function(data, code)
133 if code == 200 then 133 if code == 200 then
134 item.data = data; 134 item.data = data;
135 if callback then callback(item) end 135 if callback then callback(item) end
136 item.last_update = time(); 136 item.last_update = time();
137 elseif code == 304 then 137 elseif code == 304 then
174 174
175 --module:log("debug", "subscription request, body: %s", body); 175 --module:log("debug", "subscription request, body: %s", body);
176 176
177 --FIXME The subscription states and related stuff 177 --FIXME The subscription states and related stuff
178 feed.subscription = want; 178 feed.subscription = want;
179 http.request(feed.hub, { body = body }, function(data, code, req) 179 http.request(feed.hub, { body = body }, function(data, code)
180 module:log("debug", "subscription to %s submitted, status %s", feed.node, tostring(code)); 180 module:log("debug", "subscription to %s submitted, status %s", feed.node, tostring(code));
181 if code >= 400 then 181 if code >= 400 then
182 module:log("error", "There was something wrong with our subscription request, body: %s", tostring(data)); 182 module:log("error", "There was something wrong with our subscription request, body: %s", tostring(data));
183 feed.subscription = "failed"; 183 feed.subscription = "failed";
184 end 184 end