handle broken headers

This commit is contained in:
j 2014-04-23 15:38:38 +02:00
commit 8212c28ac7

View file

@ -231,7 +231,15 @@ class SQLiteCache(Cache):
else: else:
compressed = 0 compressed = 0
data = sqlite3.Binary(data) data = sqlite3.Binary(data)
t = (url_hash, domain, url, post_data, json.dumps(headers), created,
#fixme: this looks wrong
try:
_headers = json.dumps(headers)
except:
for h in headers:
headers[h] = headers[h].decode(detect_encoding(headers[h]))
_headers = json.dumps(headers)
t = (url_hash, domain, url, post_data, _headers, created,
data, only_headers, compressed) data, only_headers, compressed)
c.execute(u"""INSERT OR REPLACE INTO cache values (?, ?, ?, ?, ?, ?, ?, ?, ?)""", t) c.execute(u"""INSERT OR REPLACE INTO cache values (?, ?, ?, ?, ?, ?, ?, ?, ?)""", t)