From 1a9f66f8b6fb54cf643862992e119a9952fee388 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 27 Jan 2017 00:07:38 -0800 Subject: [PATCH] mementoindexsource: treat missing Link header as non-memento/not found --- pywb/webagg/indexsource.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pywb/webagg/indexsource.py b/pywb/webagg/indexsource.py index ed4887a7..438a458b 100644 --- a/pywb/webagg/indexsource.py +++ b/pywb/webagg/indexsource.py @@ -317,12 +317,17 @@ class MementoIndexSource(BaseIndexSource): if res.status_code >= 400: raise NotFoundException(url) - return res.headers.get('Link') + links = res.headers.get('Link') + + if not links: + raise NotFoundException(url) + + return links def get_timemap_links(self, params): url = res_template(self.timemap_url, params) res = requests.get(url, timeout=params.get('_timeout')) - if res.status_code >= 400: + if res.status_code >= 400 or not res.text: raise NotFoundException(url) return res.text