From 709a7d156b11fe71850b468d2b789f4bf129313b Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 4 Jan 2011 12:51:51 +0000 Subject: [PATCH] fix for a bug reported by shaohua pan (UnicodeDecodeError: 'ascii' codec can't decode...) --- lib/request/basic.py | 2 ++ lib/request/connect.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/request/basic.py b/lib/request/basic.py index 40c1b567e..810c946f2 100644 --- a/lib/request/basic.py +++ b/lib/request/basic.py @@ -134,6 +134,8 @@ def decodePage(page, contentEncoding, contentType): if charset: kb.pageEncoding = charset page = getUnicode(page) + else: + page = getUnicode(page) return page diff --git a/lib/request/connect.py b/lib/request/connect.py index d45bef4a6..3278f5bf9 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -271,7 +271,7 @@ class Connect: responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, status) if responseHeaders: - logHeaders = "\n".join(["%s: %s" % (getUnicode(key.capitalize()) if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in responseHeaders.items()]) + logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in responseHeaders.items()]) logHTTPTraffic(requestMsg, "%s%s\n\n%s" % (responseMsg, logHeaders, page))