Skip to content

Commit

Permalink
NewsDownloader: update cached content and headers with response
Browse files Browse the repository at this point in the history
  • Loading branch information
Frenzie committed Jan 31, 2025
1 parent 6a2ded4 commit afd16cc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugins/newsdownloader.koplugin/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,20 @@ function NewsDownloader:processFeedSource(url, credentials, limit, unsupported_f
headers = headers,
sink = ltn12.sink.table(response_body)
})
ok = (code == 304)
logger.dbg("NewsDownloader: If-Modified-Since response", code, response_headers)
if ok then
if code == 304 then
ok = true
response = cached_response.content
-- Update cached headers.
cached_response.headers = response_headers
cache:insert(url, cached_response)
elseif code == 200 then
ok = true
response = table.concat(response_body)
-- Update cached response.
cached_response.headers = response_headers
cached_response.content = response
cache:insert(url, cached_response)
end
end
end
Expand Down

0 comments on commit afd16cc

Please sign in to comment.