From b075c222617e47a105cbcd684f3a091e98a4758e Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 5 Mar 2025 11:03:32 -0600 Subject: [PATCH] BrowserCache Chrome Block: Treat entry missing headers same as not found. #1167 #1169 --- fanficfare/browsercache/browsercache_blockfile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fanficfare/browsercache/browsercache_blockfile.py b/fanficfare/browsercache/browsercache_blockfile.py index 88bae931..71d519d0 100644 --- a/fanficfare/browsercache/browsercache_blockfile.py +++ b/fanficfare/browsercache/browsercache_blockfile.py @@ -118,10 +118,16 @@ class BlockfileCache(BaseChromiumCache): logger.debug("Reuse Counter: %d"%entry.reuseCounter) logger.debug("Creation Time: %s"%entry.creationTime) # logger.debug("Creation Time: %s"%datetime.datetime.fromtimestamp(int(entry.creationTime/1000000)-EPOCH_DIFFERENCE)) - logger.debug("b'location':%s"%entry.httpHeader.headers.get(b'location','(no location)')) + ## we've been seeing entries without headers. I suspect + ## it's the cache being written/page loading while we are + ## reading it due to not being able to duplicate after + ## seeing it. Regardless, return None to allow retry. + if not hasattr(entry.httpHeader, 'headers'): + logger.debug("\n\nCache Entry without 'headers'--cache being written?\n\n") + return None if entry_name == key: + logger.debug("b'location':%s"%entry.httpHeader.headers.get(b'location','(no location)')) location = ensure_text(entry.httpHeader.headers.get(b'location','')) - ensure_text(entry.httpHeader.headers.get(b'content-encoding','')) rawdata = None if location else self.get_raw_data(entry) return ( location,