mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
NewsDownloader: update cached content and headers with response
This commit is contained in:
committed by
Frans de Jonge
parent
d33247967e
commit
7bc8f9bd3d
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user