From 9daf64648b292f06907a11215afb6c286b2b9477 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 6 Dec 2018 10:37:22 +0100 Subject: [PATCH] Fix handling of HTTP 304 from infrastructure ws --- .../Sources/Services/InfrastructureFactory.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Passepartout/Sources/Services/InfrastructureFactory.swift b/Passepartout/Sources/Services/InfrastructureFactory.swift index 94fb02e9..e2600757 100644 --- a/Passepartout/Sources/Services/InfrastructureFactory.swift +++ b/Passepartout/Sources/Services/InfrastructureFactory.swift @@ -136,7 +136,21 @@ class InfrastructureFactory { self.lastUpdate[name] = Date() } - guard let response = response, let infra = response.value, let lastModified = response.lastModified else { + guard let response = response else { + log.error("No response from web service") + DispatchQueue.main.async { + completionHandler(nil, error) + } + return + } + if response.isCached { + log.debug("Cache is up to date") + DispatchQueue.main.async { + completionHandler(nil, error) + } + return + } + guard let infra = response.value, let lastModified = response.lastModified else { log.error("No response from web service or missing Last-Modified") DispatchQueue.main.async { completionHandler(nil, error)