comparison mod_pubsub_feeds/mod_pubsub_feeds.lua @ 5579:bc292c84f56c

mod_pubsub_feeds: Specify acceptable formats in Accept header Don't need to a condition on the etag, if it's nil it's left out.
author Kim Alvefur <zash@zash.se>
date Sun, 25 Jun 2023 23:53:15 +0200
parents b9821e9a21a2
children
comparison
equal deleted inserted replaced
5578:b9821e9a21a2 5579:bc292c84f56c
149 end 149 end
150 end 150 end
151 end 151 end
152 152
153 function fetch(item, callback) -- HTTP Pull 153 function fetch(item, callback) -- HTTP Pull
154 local headers = { }; 154 local headers = {
155 if item.etag then 155 ["If-None-Match"] = item.etag;
156 headers["If-None-Match"] = item.etag; 156 ["Accept"] = "application/atom+xml, application/x-rss+xml, application/xml";
157 end 157 };
158 http.request(item.url, { headers = headers }, function(data, code, resp) 158 http.request(item.url, { headers = headers }, function(data, code, resp)
159 if code == 200 then 159 if code == 200 then
160 if callback then callback(item, data) end 160 if callback then callback(item, data) end
161 if resp.headers then 161 if resp.headers then
162 item.etag = resp.headers.etag 162 item.etag = resp.headers.etag