summaryrefslogtreecommitdiff
path: root/cherrypy/lib/encoding.py
diff options
context:
space:
mode:
authorSylvain Hellegouarch <sh@defuze.org>2013-09-28 19:17:08 +0200
committerSylvain Hellegouarch <sh@defuze.org>2013-09-28 19:17:08 +0200
commit9719df0a9032f09410cb09695f48c743b62a244c (patch)
treefffa3a23e25394f52fefc539f77066f04ad9f31b /cherrypy/lib/encoding.py
parent75baa71db7a1fc5bf4cc6e54cfa5fb7bdfef527b (diff)
downloadcherrypy-git-9719df0a9032f09410cb09695f48c743b62a244c.tar.gz
no much point in computing the charset when it's not expected anyway
Diffstat (limited to 'cherrypy/lib/encoding.py')
-rw-r--r--cherrypy/lib/encoding.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/cherrypy/lib/encoding.py b/cherrypy/lib/encoding.py
index bcd498a1..31a6d3ab 100644
--- a/cherrypy/lib/encoding.py
+++ b/cherrypy/lib/encoding.py
@@ -90,7 +90,7 @@ class ResponseEncoder:
body.append(chunk)
self.body = body
return True
-
+
def find_acceptable_charset(self):
request = cherrypy.serving.request
response = cherrypy.serving.response
@@ -202,7 +202,7 @@ class ResponseEncoder:
ct = response.headers.elements("Content-Type")
if self.debug:
cherrypy.log('Content-Type: %r' % [str(h) for h in ct], 'TOOLS.ENCODE')
- if ct:
+ if ct and self.add_charset:
ct = ct[0]
if self.text_only:
if ct.value.lower().startswith("text/"):
@@ -224,11 +224,10 @@ class ResponseEncoder:
if do_find:
# Set "charset=..." param on response Content-Type header
ct.params['charset'] = self.find_acceptable_charset()
- if self.add_charset:
- if self.debug:
- cherrypy.log('Setting Content-Type %s' % ct,
- 'TOOLS.ENCODE')
- response.headers["Content-Type"] = str(ct)
+ if self.debug:
+ cherrypy.log('Setting Content-Type %s' % ct,
+ 'TOOLS.ENCODE')
+ response.headers["Content-Type"] = str(ct)
return self.body