From 2c504ae67ea6b17de8035cbf71d5043331bced71 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Fri, 6 Jan 2023 13:04:56 -0600 Subject: [PATCH] Change header labels to all lowercase. --- fanficfare/browsercache/browsercache_firefox2.py | 4 ++-- fanficfare/browsercache/browsercache_simple.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fanficfare/browsercache/browsercache_firefox2.py b/fanficfare/browsercache/browsercache_firefox2.py index 83d0d41f..bfb17f51 100644 --- a/fanficfare/browsercache/browsercache_firefox2.py +++ b/fanficfare/browsercache/browsercache_firefox2.py @@ -100,7 +100,7 @@ class FirefoxCache2(BaseBrowserCache): # redirect when Location header headers = metadata.get('response-headers',{}) ## seen both Location and location - location = headers.get('Location', headers.get('location','')) + location = headers.get('location','') entry_file.seek(0) rawdata = None if location else entry_file.read(metadata['readsize']) return ( @@ -181,7 +181,7 @@ def _read_entry_headers(entry_file): # else: # logger.debug("Status:(no response-head)") if 'original-response-headers' in moremetadict: - retval['response-headers'] = dict([ x.split(': ',1) for x in moremetadict['original-response-headers'].split('\r\n') if x ]) + retval['response-headers'] = dict([ (y[0].lower(),y[1]) for y in [ x.split(': ',1) for x in moremetadict['original-response-headers'].split('\r\n') if x ]]) # logger.debug(b"\n==>".join().decode('utf-8')) if 'alt-data' in moremetadict: diff --git a/fanficfare/browsercache/browsercache_simple.py b/fanficfare/browsercache/browsercache_simple.py index 978f7e08..ef654689 100644 --- a/fanficfare/browsercache/browsercache_simple.py +++ b/fanficfare/browsercache/browsercache_simple.py @@ -127,7 +127,7 @@ class SimpleCache(BaseChromiumCache): # logger.debug("Creation Time: %s"%datetime.datetime.fromtimestamp(int(response_time/1000000)-EPOCH_DIFFERENCE)) logger.debug(headers) ## seen both Location and location - location = headers.get('Location', headers.get('location','')) + location = headers.get('location','') # don't need data when redirect rawdata = None if location else _read_data_from_entry(entry_file) return ( @@ -231,7 +231,7 @@ def _read_headers(entry_file,header_size): # It is a series of null terminated strings, first is status code,e.g., "HTTP/1.1 200" # the rest are name:value pairs used to populate the headers dict. strings = entry_file.read(header_size).decode('utf-8').split('\0') - headers = dict(s.split(':', 1) for s in strings[1:] if ':' in s) + headers = dict([ (y[0].lower(),y[1]) for y in [s.split(':', 1) for s in strings[1:] if ':' in s]]) return headers