cachecontrol icon indicating copy to clipboard operation
cachecontrol copied to clipboard

KeyError: 'response'

Open FirefighterBlu3 opened this issue 6 years ago • 0 comments

Didn't investigate the actual cause, so this is debug information. Pip employs requests and requests pulls in CacheControl. It appears that the received response is all in byte form and cachecontrol is expecting str. At cachecontrol/serialize.py the cached dictionary appears as:

Try/except added by me:

    121         try:
    122             body_raw = cached["response"].pop("body")
    123         except:
    124             print(f'cached: {pprint.pformat(cached)}')
    125             raise
cached: {b'response': {b'body': b'\x1f\x8b\x08\x[...]\x00',
               b'decode_content': False,
               b'headers': {b'Accept-Ranges': b'bytes',
                            b'Cache-Control': b'max-age=600, public',
                            b'Connection': b'keep-alive',
                            b'Content-Encoding': b'gzip',
                            b'Content-Length': b'7232',
                            b'Content-Security-Policy': b"default-src 'none'; "
                                                        b'sandbox allow-top-na'
                                                        b'vigation',
                            b'Content-Type': b'text/html; charset=UTF-8',
                            b'Date': b'Sun, 04 Aug 2019 20:03:15 GMT',
                            b'ETag': b'"1+i6Q+/bMTajoUYjsBJZIw"',
                            b'Referrer-Policy': b'origin-when-cross-origin',
                            b'Server': b'nginx/1.13.9',
                            b'Strict-Transport-Security': b'max-age=31536000'
                                                          b'; includeSubDoma'
                                                          b'ins; preload',
                            b'Vary': b'Accept-Encoding',
                            b'X-Cache': b'HIT, HIT',
                            b'X-Cache-Hits': b'31, 1',
                            b'X-Content-Type-Options': b'nosniff',
                            b'X-Frame-Options': b'deny',
                            b'X-Permitted-Cross-Domain-Policies': b'none',
                            b'X-PyPI-Last-Serial': b'5437841',
                            b'X-Served-By': b'cache-iad2139-IAD, cache-mia1762'
                                            b'6-MIA',
                            b'X-Timer': b'S1564948996.655315,VS0,VE1',
                            b'X-XSS-Protection': b'1; mode=block'},
               b'reason': b'OK',
               b'status': 200,
               b'strict': 0,
               b'version': 11},
 b'vary': {b'Accept-Encoding': b'gzip, deflate'}}

FirefighterBlu3 avatar Aug 04 '19 20:08 FirefighterBlu3