From 80fd4e9fc554b3a546f4d3d0de7ded74225f6e18 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 1 Feb 2018 19:35:35 +0200 Subject: [PATCH] Source: Set Etag and last modified to None upon redirect. --- hammond-data/src/models/source.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hammond-data/src/models/source.rs b/hammond-data/src/models/source.rs index e6eb18a..aa08ad9 100644 --- a/hammond-data/src/models/source.rs +++ b/hammond-data/src/models/source.rs @@ -110,6 +110,7 @@ impl Source { // 408: Timeout // 410: Feed deleted fn match_status(mut self, res: Response) -> Result<(Self, Response)> { + self.update_etag(&res)?; let code = res.status(); match code { StatusCode::NotModified => bail!("304: skipping.."), @@ -135,6 +136,8 @@ impl Source { if let Some(url) = headers.get::() { self.set_uri(url.to_string()); + self.http_etag = None; + self.last_modified = None; self.save()?; info!("Feed url was updated succesfully."); // TODO: Refresh in place instead of next time, Not a priority. @@ -169,11 +172,7 @@ impl Source { ) -> Box> { let id = self.id(); let feed = self.request_constructor(client, ignore_etags) - .and_then(move |(mut source, res)| { - source.update_etag(&res)?; - Ok(res) - }) - .and_then(move |res| response_to_channel(res, pool)) + .and_then(move |(_, res)| response_to_channel(res, pool)) .and_then(move |chan| { FeedBuilder::default() .channel(chan) @@ -213,6 +212,7 @@ impl Source { let work = client .request(req) .map_err(From::from) + // TODO: tail recursion loop that would follow redirects directly .and_then(move |res| self.match_status(res)); Box::new(work) }