From dae4aee6367cfb3052954f62df65aa4bae526353 Mon Sep 17 00:00:00 2001 From: Erik Chen Date: Thu, 9 Apr 2015 18:57:48 -0400 Subject: [PATCH] Normalize accept-encoding header. --- httparchive.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/httparchive.py b/httparchive.py index b1f509c..17ffa9c 100755 --- a/httparchive.py +++ b/httparchive.py @@ -610,11 +610,12 @@ def _TrimHeaders(cls, headers): # TODO(tonyg): Strip sdch from the request headers because we can't # guarantee that the dictionary will be recorded, so replay may not work. if 'accept-encoding' in headers: - headers['accept-encoding'] = headers['accept-encoding'].replace( - 'sdch', '') - # A little clean-up - if headers['accept-encoding'].endswith(','): - headers['accept-encoding'] = headers['accept-encoding'][:-1] + accept_encoding = headers['accept-encoding'] + accept_encoding = accept_encoding.replace('sdch', '') + accept_encoding = accept_encoding.replace(' ', '') + if accept_encoding.endswith(','): + accept_encoding = accept_encoding[:-1] + headers['accept-encoding'] = accept_encoding undesirable_keys = [ 'accept', 'accept-charset', 'accept-language', 'cache-control', 'connection', 'cookie', 'keep-alive', 'method',